Re: [PHP] Re: difference between php3 and php4
This error comes when trying to fetch data from a result set but there is no such because there was a problem with the query. Try var_dump($res) and you will see - 0. 0 is not a valid number for resource of type mysql or any other resource. To prevent this every time when using a resource identificator do : if ($res){ ... }else{ echo something went wrong;;} I think the problem is etiher the sql query is not successful or php cannot connect to the mysql. $db = mysql_connect(localhost, , ); the username is empty?? Regards, Andrey Hristov - Original Message - From: Todor Stoyanov [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 22, 2002 6:12 PM Subject: [PHP] Re: difference between php3 and php4 You must first get the number of record set rows. The warning is because you trying to fetch a non existing row. Toni Baker [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Warning: Supplied argument is not a valid MySQL result resource in c:\program files\apache group\apache\cgi-bin\emp.php3 on line 10 $db = mysql_connect(localhost, , ); mysql_select_db(employee,$db); $result = mysql_query(SELECT * FROM employees,$db); echo table border=0; echo tr; echo td bgcolor=#FAFOE6 colspan=2BName/B/td; echo td bgcolor=#FAFOE6BAddress/B/td; echo td bgcolor=#FAFOE6BPosition/B/td; echo /tr; while($row = mysql_fetch_row($result)) { $fname = $row[1]; $lname = $row[2]; $address = $row[3]; $position = $row[4]; echo tr bgcolor=#C6E7DE; echo td$fname/td; echo td$lname/td; echo td$address/td; echo td$position/td; echo /tr; } This script works in php3 but not in windows php4. The error message above points to the mysql_fetch_row function. Does this function work differently in php4? If not, what else might cause this script to work in php3 and not in php4? __ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com -- 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] Re: difference between php3 and php4
The warning means the query failed in mysql. Perhaps it failed in the connect. You do not need the number of rows. To determine what the problem is, ALWAYS include a die() clause: $db = mysql_connect(localhost, , ) or die(Error: .mysql_error()); mysql_select_db(employee,$db) or die(Error: .mysql_error()); $result = mysql_query(SELECT * FROM employees,$db) or die(Error: .mysql_error()); -Original Message- From: Todor Stoyanov [mailto:[EMAIL PROTECTED]] Sent: Friday, February 22, 2002 10:13 AM To: [EMAIL PROTECTED] Subject: [PHP] Re: difference between php3 and php4 You must first get the number of record set rows. The warning is because you trying to fetch a non existing row. Toni Baker [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Warning: Supplied argument is not a valid MySQL result resource in c:\program files\apache group\apache\cgi-bin\emp.php3 on line 10 $db = mysql_connect(localhost, , ); mysql_select_db(employee,$db); $result = mysql_query(SELECT * FROM employees,$db); echo table border=0; echo tr; echo td bgcolor=#FAFOE6 colspan=2BName/B/td; echo td bgcolor=#FAFOE6BAddress/B/td; echo td bgcolor=#FAFOE6BPosition/B/td; echo /tr; while($row = mysql_fetch_row($result)) { $fname = $row[1]; $lname = $row[2]; $address = $row[3]; $position = $row[4]; echo tr bgcolor=#C6E7DE; echo td$fname/td; echo td$lname/td; echo td$address/td; echo td$position/td; echo /tr; } This script works in php3 but not in windows php4. The error message above points to the mysql_fetch_row function. Does this function work differently in php4? If not, what else might cause this script to work in php3 and not in php4? __ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com -- 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