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
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
Post Description: warning: mysql_fetch_row(): supplied argument is not a valid mysql result resource in
POST# 559
Posted On: Fri Feb 29, 2008 12:01 pm
bret
Topic: 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?


Mon Jun 18, 2007 5:29 pm
1
webune
Reply #1170
can you provide your sql query please?
Mon Jun 18, 2007 5:30 pm
2
bret
Reply #1171
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);
Mon Jun 18, 2007 5:33 pm
3
webune
Reply #1172
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
Mon Jun 18, 2007 5:34 pm
4
bret
Reply #1173
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
Mon Jun 18, 2007 5:36 pm
5
webune
Reply #1174
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
Mon Jun 18, 2007 5:38 pm
6
bret
Reply #1175
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.

What do you think?

* name:  

* email:  

* Please enter comments:


Receive Replies on my Comments
(An email will be sent to you when someone replies to your comments)

Add image to comments
yes no             upload