Error Echoing Database(DB)

Okay, I’ve been making a PHP commenting script, and it seems as though the last thing I need it to echo the database. For some reason, it is giving me this error:

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 ‘Resource id #6’ at line 1.

My code…

<?php
//conection
mysql_connect("localhost","root","") or die(mysql_error());
echo "Connected!";
mysql_select_db("ycomment") or die(mysql_error());
echo "DBSelected!";

//the real stuff.  oh yeah.
$show = mysql_query("SELECT * FROM comments");
echo "Query made!";
$result = mysql_query($show) or die(mysql_error());
while($show = mysql_fetch_array($result)) {
$name = $show['name'];
$commment = $row['comment'];
	echo "Name: $name";
	echo "Comment: $comment";
}
?>

mysql_query() takes a string as a parameter and returns a resource identifier

[php]
// After this call $show contains a resource identifier, not a string
$show = mysql_query(“SELECT * FROM comments”);

// Then here we are passing mysql_query a resource identifier instead of a SQL query
$result = mysql_query($show) or die(mysql_error());
[/php]

I think what you meant to do was something like this:
[php]

<?php //conection mysql_connect("localhost","root","") or die(mysql_error()); echo "Connected!"; mysql_select_db("ycomment") or die(mysql_error()); echo "DBSelected!"; //the real stuff. oh yeah. $result = mysql_query("SELECT * FROM comments"); echo "Query made!"; while($show = mysql_fetch_array($result)) { $name = $show['name']; $commment = $row['comment']; echo "Name: $name"; echo "Comment: $comment"; } ?>

[/php]

I’ve tried that, and it doesn’t work either. Any suggestions?

Are you getting the same error message?

I’m not sure what the problem is anymore, it had something to do with using the wrong user and some blah blah simple mistake. ;D

Sponsor our Newsletter | Privacy Policy | Terms of Service