Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 12-19-2003, 10:02 PM   #1 (permalink)
MysticalMatt517
Registered User
 
Join Date: Dec 2003
Posts: 2
MysticalMatt517 is on a distinguished road
Send a message via ICQ to MysticalMatt517 Send a message via AIM to MysticalMatt517 Send a message via Yahoo to MysticalMatt517
Angry fwrite() issues

Greetings, I have been trying to resolve this one for a while, but keep running into the same brick wall. I don't see what I'm doing different from everyone else.

First, the error messages:

Warning: fwrite(): supplied argument is not a valid stream resource

Warning: fclose(): supplied argument is not a valid stream resource

Warning: unlink(tempHitlist.html): Permission denied

Now the badly written code causing the issue ;-]

PHP Code:
function hitlistHTML()
{
// Include the mySQL connection variables in the function
        
include('hitlist_config.php');
// Sets the files we'll be using
        
$srcURL $installPath 'hitlist.php';
        
$tempFilename 'tempHitlist.html';
        
$targetFilename 'hitlist.html';
// Begin by deleting temporary file in case it was not cleaned up for some reason
        
@unlink($tempFilename);
// Open connection to source file
        
$dynPage fopen($srcURL'r');
// Check for errors
        
if (!$dynPage)
        {
                die(
"<P>Unable to load $srcURL. The hitlist.html file has not been updated!</P>");
        }
// Read the contents of the URL into a PHP variable. Specify that up to 1MB of data can be read in.
        
$htmlData fread($dynPage1024*1024);
// Close connection to source file
        
fclose($dynPage);
// Create the temporary file so we can write to it
        
$tempFile fopen($tempFilename'w');
// Check for errors
        
if (!$tempFile)
        {
                die(
"<P>Unable to open temporary file ($tempFilename) for writing. The hitlist.html file has not
                    been updated!</P>"
);
        }
// Write the data for the hitlist.html file into the temporary file
        
fwrite($tempfile$htmldata);
// Close the temporary file
        
fclose($tempfile);
// Copy the temporary file over the hitlist.html file
        
$ok copy($tempFilename$targetFilename);
// Delete temporary file
        
unlink($tempFilename);
// If all this has wen't right, return back that everything is cool
        
if (!isset($ok))
        {
                return 
true;
        }

Any clue what's causing this? For the record I threw the first error into google to see what it would bring back. I didn't get any info about the error, but I did find a ton of sites suffering from the same problem ;-]. Anyone know what I'm doing wrong?
MysticalMatt517 is offline   Reply With Quote
Old 12-19-2003, 11:10 PM   #2 (permalink)
MysticalMatt517
Registered User
 
Join Date: Dec 2003
Posts: 2
MysticalMatt517 is on a distinguished road
Send a message via ICQ to MysticalMatt517 Send a message via AIM to MysticalMatt517 Send a message via Yahoo to MysticalMatt517
nevermind

Nevermind... I need to be give "Code Doofus of the Month" award... It's taken me two weeks to discover that I declared $tempFile and called on $tempfile. ;-]

Thanks anyway.
MysticalMatt517 is offline   Reply With Quote
Old 12-19-2003, 11:27 PM   #3 (permalink)
Epsilon
Regular Contributor
 
Epsilon's Avatar
 
Join Date: Mar 2003
Location: Las Vegas, NV
Posts: 127
Epsilon is on a distinguished road
Yep, the camel caps will get you every time...
__________________
--Epsilon--
Epsilon is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issues with Javascript creed HTML, XML, Javascript, AJAX 8 08-23-2004 09:11 AM
Double quotes in fwrite NirTivAal PHP 8 12-08-2003 08:13 AM
Permission Issues, Filesize() Ect JeC PHP 1 06-11-2003 09:34 PM
DVD-ROM LAPTOP Hardware Issues rdove Windows 2 02-21-2003 07:24 PM
void(); issues w00t Standard C, C++ 7 12-16-2002 05:14 AM


All times are GMT -8. The time now is 03:58 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting