RE: [PHP] mysql_num_rows() error
And which database are you using?? (hint - mysql_select_db() might be a good idea ...) > -Original Message- > From: Phil Powell [mailto:[EMAIL PROTECTED]] > > Anyone know why this is happening? I have mySQL on Win2000 > Server with IIS > > and PHP: >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows() error
Are you actually checking that the query result is valid? $conn = mysql_connect('localhost', "xxx", "yyy") or die('Could not connect to db'); $result = mysql_query('select * from blah', $conn); if ($result) { echo "Number of rows: " . mysql_num_rows($result); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_row($result)) { for ($i = 0; $i < sizeOf($row); $i++) { echo "$i: " . $row[$i] . ""; } } } } else { echo mysql_error($conn); } -Original Message- From: Phil Powell [mailto:[EMAIL PROTECTED]] Sent: Friday, 10 January 2003 1:46 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [PHP] mysql_num_rows() error > Anyone know why this is happening? I have mySQL on Win2000 Server with IIS > and PHP: > > mysql_num_rows(): supplied argument is not a valid MySQL result resource > > Here is my code: > >$conn = mysql_connect('localhost', "xxx", "yyy") or die('Could not connect > to db'); > $result = mysql_query('select * from blah'); > echo "Number of rows: " . mysql_num_rows($result); > if (mysql_num_rows($result) > 0) { >while ($row = mysql_fetch_row($result)) { > for ($i = 0; $i < sizeOf($row); $i++) { > echo "$i: " . $row[$i] . ""; > } >} > } > ?> > > It couldn't get any simpler. I just installed mySQL on my machine and am > trying to see what I can do with it giving Win2K and IIS. > > AUGH! Thanx > Phil > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows() error
You query is incorrect. Try doing the same query from the MySQL clent. |-> -Original Message- |-> From: Phil Powell [mailto:[EMAIL PROTECTED]] |-> Sent: Thursday, January 09, 2003 7:46 PM |-> To: [EMAIL PROTECTED]; [EMAIL PROTECTED] |-> Subject: [PHP] mysql_num_rows() error |-> |-> |-> > Anyone know why this is happening? I have mySQL on |-> Win2000 Server with |-> > IIS and PHP: |-> > |-> > mysql_num_rows(): supplied argument is not a valid MySQL result |-> > resource |-> > |-> > Here is my code: |-> > |-> > > $conn = mysql_connect('localhost', "xxx", "yyy") or |-> die('Could not |-> connect |-> > to db'); |-> > $result = mysql_query('select * from blah'); |-> > echo "Number of rows: " . mysql_num_rows($result); |-> > if (mysql_num_rows($result) > 0) { |-> >while ($row = mysql_fetch_row($result)) { |-> > for ($i = 0; $i < sizeOf($row); $i++) { |-> > echo "$i: " . $row[$i] . ""; |-> > } |-> >} |-> > } |-> > ?> |-> > |-> > It couldn't get any simpler. I just installed mySQL on |-> my machine and |-> > am trying to see what I can do with it giving Win2K and IIS. |-> > |-> > AUGH! Thanx |-> > Phil |-> > |-> |-> |-> -- |-> PHP General Mailing List (http://www.php.net/) |-> To unsubscribe, visit: http://www.php.net/unsub.php |-> |-> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows error
Well, those error normaly appear when you've got something wrong in your sql statement. Make sure there is some information stored in your database, empty tables are sometimes troublesome. What do you use $link for? $sql = "select USUARIO from docente where USUARIO = '$usuario'"; $result = mysql_query($sql, $link); if (mysql_num_rows($result) == 1) Bye *** Wilmar Pérez Network Administrator Library System Tel: ++57(4)2105145 University of Antioquia Medellín - Colombia 2002 *** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows error
Omar Campos wrote: > I get the next warning: > Warning: mysql_num_rows(): supplied argument is not a valid MySQL result > resource in /home/olimpiad/public_html/base/alta1.php on line 34 This usually means that the SQL query failed. You can check the value returned by mysql_query to see if this is the case - it will be FALSE if it failed. In this case my guess would be that the backticks are not valid string delimeters. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows error
Hi Nick, > I am new to php and that the folowing error: > Warning: mysql_num_rows(): supplied argument > is not a valid MySQL result resource in > /home/tbonestu/public_html/smallimages.php > > i dont know what i am doing wrong here is the code: > > @ $db = mysql_pconnect(connect info); Along with the other suggestions to check your $query variable, you should change this line to : $db = @mysql_pconnect($whatever); The @ goes in front of the function call, not the variable, if you want to suppress any potential error messages generated by the function. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows error
>> I am new to php and that the folowing error: Warning: mysql_num_rows(): >> supplied argument is not a valid MySQL result resource in >> /home/tbonestu/public_html/smallimages.php >> >> i dont know what i am doing wrong here is the code: >> >> @ $db = mysql_pconnect(connect info); >> >> mysql_select_db("images"); >> $query = "select * from images where type =".$type.""; $result = >> mysql_query($query); $num_results = mysql_num_rows($result); >That generally means your query failed. Try to echo mysql_error() after your query to see what the problem is. You probably need quotes around $type or $type has no value. You also have too many quotes on the $query line, try echoing your $query variable to see if it reads properly. Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows error
> I am new to php and that the folowing error: Warning: mysql_num_rows(): > supplied argument is not a valid MySQL result resource in > /home/tbonestu/public_html/smallimages.php > > i dont know what i am doing wrong here is the code: > > @ $db = mysql_pconnect(connect info); > > mysql_select_db("images"); > $query = "select * from images where type =".$type.""; > $result = mysql_query($query); > $num_results = mysql_num_rows($result); That generally means your query failed. Try to echo mysql_error() after your query to see what the problem is. You probably need quotes around $type or $type has no value. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows error
Hi, Sunday, September 23, 2001, 3:25:02 PM, you wrote: NV> I am new to php and that the folowing error: Warning: mysql_num_rows(): NV> supplied argument is not a valid MySQL result resource in NV> /home/tbonestu/public_html/smallimages.php NV> i dont know what i am doing wrong here is the code: NV> @ $db = mysql_pconnect(connect info); NV> mysql_select_db("images"); NV> $query = "select * from images where type =".$type.""; NV> $result = mysql_query($query); NV> $num_results = mysql_num_rows($result); Do it this way $query = "select * from images where type = '$type'"; or if you prefer $query = "select * from images where type = '".$type."'"; PS check your comps date its a year out -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php