Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: php errors

  1. #1
    New to the CF scene
    Join Date
    Aug 2002
    Location
    Lymington, UK
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php errors

    Hi

    I am getting the following error on my php scrips on the top of every page:

    "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /www/w........."

    Can anybody help me?


    Here's part of the code for the main page (the point where the error occurs is in the third code paragraph, and the 4th line down):


    mysql_connect("$DBHost","$DBUser","$DBPass");
    $old=date("z")-1;
    mysql("$DBName","DELETE FROM Users WHERE Date < $old");

    $result=mysql("$DBName","SELECT CartItemsID,Date FROM CartItems");
    while ($row=mysql_fetch_row($result)) {
    $CII=$row[0];
    $CDa=$row[1];
    $pieces=explode(":",$CDa);
    $DCHK=$pieces[1];
    if ($DCHK < $old) {
    mysql("$DBName","DELETE FROM CartItems WHERE CartItemsID = '$CII'");
    }
    }


    if ($UID != "") {
    $result=mysql("$DBName","SELECT * FROM Users WHERE User='$UID'");
    $num=mysql_num_rows($result);
    if ($num == "0") {
    $dt=date("YmdHis");
    $UID="$dt$REMOTE_ADDR";
    $date=date("z");
    mysql("$DBName","INSERT INTO Users VALUES ('$UID','$date')");
    Header("Location: $PHP_SELF?UID=$UID");
    }
    }



    Paul

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    North East England
    Posts
    853
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I could be mistaken but you use the variable $result twice for different things.
    [+] Computer/PC issues [+] Silverpaw3D
    ------------------------------------------------
    Never buy a dwarf with learning disabilities...

    ...it's not big, and it's not clever.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It seems like this line

    PHP Code:
    $result=mysql("$DBName","SELECT * FROM Users WHERE User='$UID'"); 
    does not return a valid mysql result list, i.e. something went wrong on the way querying the database. You might check for that case by inserting this after the line mentioned above:

    PHP Code:
    if (!$result) {
      echo 
    "sth. went wrong: " mysql_error();

    This will print out any errors with the SQL, if there were any, it's quite useful for debugging, I use that always when I develop. The error description should give you a hint what went wrong.

    BTW: I don't know of a mysql() function, so I suppose it's one you created. But you definitely don't need the double quotes around the variable $DBName.

  • #4
    New to the CF scene
    Join Date
    Aug 2002
    Location
    Lymington, UK
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I added the mysql_error line and it seems like a table doesn't exist, so I created the table in the database and now keep getting an error saying:


    Script Error
    The script did not produce proper HTTP headers. Please see the
    error log to see the detail of the errors. Depending on the server configuration, you can also run this script under CGIWrap debugging. Usually, either rename or link the script temporarily to a file which ends with .cgid extension, or add a AddHandler cgi-script-debug .cgi line to your .htaccess file.



    Anyone?? I have to get this working by the weekend. It works fine locally but not remotely on the server......


    Paul

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    When exactly do you get this error? I'm quite baffled, I've never seen this error come from incorrect php scripts. Looks to me like your server is not configured properly, but that's hard to determine from distance.

  • #6
    New to the CF scene
    Join Date
    Aug 2002
    Location
    Lymington, UK
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Don't know what's going on but seems to be working now...

    Must have been a temporary server glitch


    cheers,
    Paul


  •  

    Posting Permissions

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