[solved]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

[solved]

Post by gaogier »

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/gaogier/public_html/sreport.php on line 15
The Special Reports guide requested cannot be found

i dont know what that error means, if you can explain it, ill be greatful
Last edited by gaogier on Tue Apr 11, 2006 2:03 pm, edited 1 time in total.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

show your code
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

the code has been cut down to what i think is the error

Code: Select all

function spview($id) {


require_once ('../mysql_connect.php');//connect to db
 /* query for item */
    $query = "SELECT * FROM sp WHERE id=$id";
    $result = mysql_query ($query);
    
    /* if we get no results back, error out */
$numrtn = mysql_num_rows($result); /*line of error */

    if ($numrtn == 0) {
        echo "The Special Reports guide requested cannot be found\n";
        echo $id;
        return;
    }
Red Blaze
Forum Commoner
Posts: 40
Joined: Mon Mar 27, 2006 3:45 pm

Post by Red Blaze »

gaogier wrote:the code has been cut down to what i think is the error

Code: Select all

function spview($id) {


require_once ('../mysql_connect.php');//connect to db
 /* query for item */
    $query = "SELECT * FROM sp WHERE id=$id";
    $result = mysql_query ($query);
    
    /* if we get no results back, error out */
$numrtn = mysql_num_rows($result); /*line of error */

    if ($numrtn == 0) {
        echo "The Special Reports guide requested cannot be found\n";
        echo $id;
        return;
    }
You may want to try:

Code: Select all

$query = 'SELECT * FROM sp WHERE id = "'. $id .'"';
Unless $id is empty, then you need to give $id a correct value. That's what I think.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

$result = mysql_query ($query) or die(mysql_error());

Always include error reporting, as it will give you useful information as to why your error occured
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

solved, thanks
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Thanks for posting your solution to help others :roll:
Last edited by JayBird on Tue Apr 11, 2006 4:06 pm, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

gaogier wrote:solved, thanks
Also please don't erase the topic of this thread -- just prefix it with [solved], others may find this thread useful aswell..
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

it was just a typo

it was ment to be id, instead it was ud

it was deep in the code, so, my advise check you havnt done any typos, make sure all fields match
Post Reply