Page 1 of 1

Problem with query...

Posted: Sat Nov 29, 2003 8:47 am
by partiallynothing
I don't know why this code doesn;t work!

Code: Select all

<?php
echo "<BR>";
$query = "SELECT id, name, desc, url FROM c_forums ORDER BY id DESC";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
	echo "<b>{$row['id']}. {$row['name']}</b> - <a href="{$row['url']}" target="_blank">{$row['name']}</a><BR>{$row['desc']}<BR><BR>"; }
?>
With the above, I get this error"You have an error in your SQL syntax near 'desc, url FROM c_forums ORDER BY id DESC' at line 1". Thanks for any help!

Posted: Sat Nov 29, 2003 10:28 am
by d3ad1ysp0rk
are you sure all of those tables/fields exist? (did you enter the correct names?)

Posted: Sat Nov 29, 2003 10:52 am
by Weirdan
desc is reserved word (it's used in ORDER BY clause).