Forum Moderators: coopster

Message Too Old, No Replies

SQL Problem

Problem with some SQL

         

bysonary

6:32 pm on Feb 11, 2007 (gmt 0)

10+ Year Member



hello

I am using the following code


<?php
include '/home/www/juttuffi/dbc.php';

$query1 = mysql_query("SELECT * FROM tquestions ORDER BY qid ASC");

if (mysql_num_rows == 0)
{
echo "There is nothing in the database";
}
else
{
echo '<form method="post" action="answeradd.php">';
echo '<select name="quest">';

while ($qrow = mysql_fetch_array($query1,MYSQL_ASSOC))
{
echo "<option>".$qrow['question']."</option>";
}
echo '</select>';
echo '</form>';
}
mysql_close($dbc);
?>

I know there is stuff in the database I can see it using phpmyadmin and when i perform the query SELECT * FROM tquestions ORDER BY qid ASC I get the result I want in phpmyadmin but when I do it using the above code I get There is nothing in the database

Can anyone help me out here and tell me if and possibly where I am going wrong here?

[edited by: bysonary at 6:35 pm (utc) on Feb. 11, 2007]

phparion

6:35 pm on Feb 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



yeah, you have problem here

if (mysql_num_rows == 0)

you are not passing valid arguments to mysql_num_rows.

it should be like

if (mysql_num_rows($query1) == 0)

bysonary

6:36 pm on Feb 11, 2007 (gmt 0)

10+ Year Member



Cheers mate I understand the error now, I forgot to put ($query1) with the mysql_num_rows_ function thanks for pointing that out.