Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: fclose() error and can't figure it out!

  1. #11
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    okay I made the whoami.php and it said my usr name

    I am not sure what you mean for me to do with this:

    Code:
    $ chown -R `php whoami.php` scores
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  2. #12
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It's a shell command. Run it as the user that currently owns the files. It will change the ownership of scores and all files under it to the user output by whoami.php.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #13
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    using putty I did that command..

    it responded with:

    chown 'php whoami.php' :invalid user


    :cry: :whine: :cry:
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #14
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Those are backticks (`) not apostrophes ('). I only used them for simplicity; you could just as well substitute the output of the whoami.php file for `php whoami.php`.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #15
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    I am back after a long delay of this stupid thing called real life...

    I have verified with the host, and the folders are most definetly mine. It is something in this php code I am sure... I just don't know what.

    here is the complete script:

    Code:
    <?php
    
    	$winscore = (int)$winscore;
    
    	// Create a Blank File if it doesn't already exist
    	if (!file_exists($filename))
    	{
    		$file=fopen($filename, "w");
    		fclose ($file);
    	}
    
    	// Read the file in
    	$oscores = file ($filename);
    	$numreadin = count($oscores);
    
    	// Break out the data into a new 2-d array called $tscores
    	for ($i = 0; $i < $numreadin; $i++)
    	{
    		$g = unserialize($oscores[$i]);
    		$tscores[$i][0] = $g[0];
    		$tscores[$i][1] = $g[1];
    	}
    
    	// Fill in any missing data with none/0
    	for ($i = $numreadin; $i < $scoresize; $i++)
    	{
    		$tscores[$i][0] = 0;
    		$tscores[$i][1] = "";
    	}
    
    	// Process the actions	
    
    	// Insert a score/name
    	if ($action == "INSERT")
    	{
    
    		// Add name to end of list, and sort
    		$tscores[$scoresize + 1][0] = $winscore;
    		$tscores[$scoresize + 1][1] = $winname;
    		rsort ($tscores);
    
    		$file=fopen($filename, "w");
    
    		// Write them out
    		for ($i = 0; $i < $scoresize; $i++)
    		{
    			$st = serialize($tscores[$i]) . "\n";
    			fputs($file, $st);
    		}
    
    		fclose($file);
    	}
    
    	// Clear the list	
    	if ($action == "CLEAR")
    	{
    
    		$k[0] = 0;
    		$k[1] = "no-one";
    		$ser = serialize($k);
    
    		$file=fopen($filename, "w");
    
    		for ($i = 0; $i < $scoresize; $i++)
    		{
    			$st = $ser . "\n";
    			fputs($file, $st);
    		}
    
    		fclose($file);
    	}
    
    	// Process the OUTPUT options
    	if ($viewtype == "HTML")
    	{
    	  // HTML PAGE CREATED HERE
    	  ?>
    
    
    		
    <table cellpadding=2 cellspacing=2 border=0 width="330">
      <tr align=center> 
        <th bgcolor="#663300" width="80"><font color="#ffff00" face="Arial, Helvetica, sans-serif" size="1">Rank</font></th>
        <th bgcolor="#663300" width="126"><font color="#FFFF00" face="Arial, Helvetica, sans-serif" size="1">Name</font></th>
        <th bgcolor="#663300" width="104"><font color="#FFFF00" face="Arial, Helvetica, sans-serif" size="1">Score</font></th>
      </tr>
      <?
    	
    		for ($i = 0; $i < $scoresize; $i++)
    		{
    			echo ("<tr bgcolor='#669933' align='center'><td><font size='1' face='Arial, Helvetica, sans-serif'>");
    			echo ($i + 1);
    			echo ("</font></td><td><font size='1' face='Arial, Helvetica, sans-serif'>");
    			echo ($tscores[$i][1]);
    			echo ("</font></td><td><font size='1' face='Arial, Helvetica, sans-serif'>");
    			echo ($tscores[$i][0]);
    			echo ("</font></td></tr>");
    		}
    
      	  ?>
    </table>
    	  <?
    
    	}
    
    	// FLASH DATA CREATED HERE
    	if ($viewtype == "FLASH")
    	{
    		for ($i = 0; $i < $scoresize; $i++)
    		{
    			echo ("name" . $i . "=");
    			echo ($tscores[$i][1]);
    			echo ("&score" . $i . "=");
    			echo ($tscores[$i][0]);
    			echo ("&");
    		}
    	}
    
    ?>
    the error I get is:

    Code:
    [09-May-2006 15:55:27] PHP Warning:  fclose(): supplied argument is not a valid stream resource in /path/to/the/folder/scores.php on line 9
    Any ideas? I am just befuddled with this whole thing.

    I really do not want to have to code 6000 lines of action script again just to make an external high scores list for Flash... sigh.. anything? anyone?

    Thanks guys!
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #16
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Is $filename defined?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #17
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    in the Flash file I have it defined as this:


    Code:
    _global.scoreFile = "scores/highscores.sco";
    This tells the flash file that scores/highscores.sco is the file name to use everytime "scoreFile" is called

    In the 2 places I call the script (load and submit) I have this:

    Code:
    _root.filename = _global.scoreFile;

    As far as in the php file itself, I guess not, if it's not in there. All I do know about this php file (I didn't write it, obv. ) is that it is to open highscores.sco, if it is already there, and create it if it does not yet exist.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  8. #18
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Well, that's probably your problem, then Define $filename = "scores/highscores.sco"; somewhere before calling that code.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #19
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    I will give that a try and let you know!

    Thanks Twey!
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  10. #20
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Well, that ALMOST worked! LOL

    I added the definition and now it created the highscores.sco file like it was supposed to.

    That tells me everything is reading and sending just fine.

    I don't get an error log either!

    The only problem now, is that it doesn't write to the sco file. It stays blank.

    I CHMOD to 777 on virtually every file there, and still nothing.

    I think I need another break. I can't afford to throw another computer out the window.

    If you have any ideas about the writing thing though I would love to hear them.

    I have a feeling I am going to have to re-do the Flash portion now though. greeeaaat... sigh.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •