Cannot figure out this error

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
SFTLOLZ
Forum Newbie
Posts: 7
Joined: Tue Jun 22, 2010 12:30 pm

Cannot figure out this error

Post by SFTLOLZ »

***
Last edited by SFTLOLZ on Mon Jul 19, 2010 12:03 am, edited 2 times in total.
Aravinthan
Forum Commoner
Posts: 84
Joined: Mon Jan 28, 2008 6:34 pm

Re: Cannot figure out this error

Post by Aravinthan »

For the header,

It must be placed before the HTML tag.

For the MYSQL,

Code: Select all

$result= "SELECT * FROM `comments` WHERE id = `$id`";
Must be:

Code: Select all

$result= "SELECT * FROM `comments` WHERE `id` = '$id'";
SFTLOLZ
Forum Newbie
Posts: 7
Joined: Tue Jun 22, 2010 12:30 pm

Re: Cannot figure out this error

Post by SFTLOLZ »

Thanks for the response,

It is still returning this error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home1/sftlolzc/public_html/likes.php on line 6
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Cannot figure out this error

Post by AbraCadaver »

SFTLOLZ wrote:Thanks for the response,

It is still returning this error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home1/sftlolzc/public_html/likes.php on line 6
No, look at what Aravinthan said about the query. Tick marks ` go around field names, quotes ' go around string values like $id. If you would carry on your or die() logic you would see that $result is not valid because your query failed.

Code: Select all

$result = "SELECT * FROM `comments` WHERE id = `$id`" or die(mysql_error());
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
SFTLOLZ
Forum Newbie
Posts: 7
Joined: Tue Jun 22, 2010 12:30 pm

Re: Cannot figure out this error

Post by SFTLOLZ »

I did it, I did it by typing it in, then copy and pasting. Same error both times.
Aravinthan
Forum Commoner
Posts: 84
Joined: Mon Jan 28, 2008 6:34 pm

Re: Cannot figure out this error

Post by Aravinthan »

Can you repost your code please?

Also make sure that there is a table colums with an field called id and a field called likes.

look for some type...
SFTLOLZ
Forum Newbie
Posts: 7
Joined: Tue Jun 22, 2010 12:30 pm

Re: Cannot figure out this error

Post by SFTLOLZ »

I figured it out, thank you for your help.
Post Reply