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!
That error means that the query is invalid syntax. Note you should NOT be using asterisks in your query as a list of comma separated values is going to be much faster. You can debug your script with a combination of mysql_error(), mysql_errno() and echoing the query back to the page. The following was tested locally and was found to run flawlessly.
Thanks kriek. I was looking through some of my past posts and thought "ahh.... <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>! I didn't tell this guy that he helped me out".
<?php
$ans="";
$sql_query = "select * from cs15replies where subject='$subject'";
$result = mysql_query($sql_query);
if(mysql_num_rows($result))
{
while ($row = mysql_fetch_array($result))
{
$ans = $row['name'];
}
}
else
$ans = "No Replies";
echo $ans;
I hope this code is also helpful to you.
?>
Last edited by derek on Mon Aug 18, 2003 5:24 am, edited 2 times in total.
Use [syntax=php]tags rather than[/syntax][syntax=php]tags when you're posting a php code snippet. It really helps us follow the code, and sometimes it even points out syntax errors via the code highlighting that people otherwise can't detect.[/syntax]
if ($result)
{
if (@mysql_num_rows($result) > 0)
{
while (mysql_fetch_array($result))
{
// Code here
}
}
else
{
//No rows returned
}
}
else
{
// Result not valid
}