Warning: Mysql_fetch_row(): Supplied Argument Is Not A Valid MySQL Result Resource In



Warning: Mysql_fetch_row(): Supplied Argument Is Not A Valid MySQL Result Resource In
 (382) Find work at Home Jobs
Warning: Mysql_fetch_row(): Supplied Argument Is Not A Valid MySQL Result Resource In
Post Description:
Post Tags: warning, mysql, fetch, row, supplied, argument, is, not, a, valid, mysql, result, resource, in
This Post Has Been Viewed 348 Times Since Mon Jun 18, 2007 5:29 pm Posted By bret with 6 replies
Warning: Mysql_fetch_row(): Supplied Argument Is Not A Valid MySQL Result Resource In
ok, so how do you fix this error?

i have a script that i created and i can't get passed this.

i was told by a friend that you guys and webune have excellent support, how can you help me?

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About Warning: Mysql_fetch_row(): Supplied Argument Is Not A Valid MySQL Result Resource In




:: 1 :: #7167 - Reply By webune On Mon Jun 18, 2007 5:29 pm
can you provide your sql query please?
:: 2 :: #7168 - Reply By bret On Mon Jun 18, 2007 5:30 pm
sure, it looks like this:

$sql = "select count(*) as total from ".$db_prefix."table where id = $id";
$result = mysql_query($sql ,$db);
$row = mysql_fetch_row($result);
:: 3 :: #7169 - Reply By webune On Mon Jun 18, 2007 5:33 pm
replace
$row = mysql_fetch_row($result);

with this
if(! $row = mysql_fetch_row($result)){echo mysql_error();}

this will show you what the error you are getting from the mysql server

post the error here ok
:: 4 :: #7170 - Reply By bret On Mon Jun 18, 2007 5:34 pm
sure, this is what i see now:

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/www/index.php on line 158

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
:: 5 :: #7172 - Reply By webune On Mon Jun 18, 2007 5:36 pm
ok, i found your problem, you need to enclose the value

replace this:
$sql = "select count(*) as total from ".$db_prefix."table where id = $id";

with this:
$sql = "select count(*) as total from ".$db_prefix."table where id = '$id'";

all i basically added was single quotes on you $id to make it look like this: '$id'

try it and let me know if it helps
:: 6 :: #7173 - Reply By bret On Mon Jun 18, 2007 5:38 pm
thanks, that worked for me.

thanks webune, i really appreciated.

im new at this, but it really helps to have guys like this, that's why i have two of my websites hosting at webune.com

thanks for your help.