Page 3 of 3 FirstFirst 123
Results 21 to 25 of 25

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

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

    Default

    "Another?" Lol!
    Use "a" instead of "w" for INSERT. Also, make sure $action (and all the other variables the script uses) is 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!

  2. #22
    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

    Hey! I still have a couple laptops to toss

    Anyway, I was on my Flash help forum trying to get help with the flash side and I got this as a reply:

    The PHP script relies on an old PHP setting (register_globals) to be turned on. This has been disabled by default - because of the security problems it causes - for several years.

    What this setting does is make PHP automatically create global variables from the data submitted to the script (e.g. GET, POST etc...) with register globals turned off, you need to extract these values yourself from an array, $_GET for GET and, unsurprisingly $_POST for POST

    With register_globals on if a variable winscore is sent to PHP using GET the variable $winscore would be created automatically. With register_globals off to create your winscore variable you might use,

    $winscore = isset($_GET['winscore']) ? (int) $_GET['winscore'] : 0;

    what this does is it uses isset check the $_GET array to see if it contains a value for the winscore variable. If winscore was sent to the script it uses (int) to typecast the value to an integer and stores the result in $winscore. If a winscore variable wasn't sent $winscore will default to 0.

    You'd need to use a similar technique to extract all the variables sent from Flash to the script. I'd suspect the cause of the error is that $filename is undefined - due to register_globals being turned off - the undefined variable causes fopen to fail, so now your variable $file doesn't contain a valid file handle. fclose then throws the warning when it is supplied with something that it can't work with.

    One thing that seems a little risky is that you're sending the filename of the scores file to the script, a devious user might spot this and start experimenting with supplying some different filenames to see what happens. It would probably be better to hard code the filename into the PHP instead of the Flash.
    Does this make sense to you? I didn't write the php in the first place so I have no idea what they are really talking about... I asked for clarification over there, but nothing....
    {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

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

    Default

    Yes. For example, if you access file.php?thing=this, with register_globals turned on, the variable $thing will exist and be equal to "this". However, without it, you must go through the script explicitly defining these variables, from the $_GET and/or $_POST arrays.
    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!

  4. #24
    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, that makes a little more sense.

    So every time there is a variable I need to make it = something.

    Okay, so here is a stupid question, how do I know what to set it equal to?

    I have tried learning this PHP stuff on my own, and it is just too hard for me. I haven't given up, but I think "re-writing" a whole php page to update it, is over my head.

    I will do it though! I just need a bit of guidance.
    {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

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

    Default

    Converting code for use without register_globals is easy. Go through your code, and wherever you see a variable that hasn't been defined, add a new declaration to the top of your page (example assumes that variable is named $camel):
    Code:
    $camel = $_GET['camel'];
    You should use $_POST rather than $_GET if you're using POST instead of GET, obviously.
    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!

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
  •