Click to See Complete Forum and Search --> : mysql_num_rows()


Anon
12-12-2001, 02:14 PM
I can not get this function to work, when using this

$forum_connect=mysql_connect("127.0.0.1","","") || die("Connection failed");

$myforum=mysql_select_db("forum") || die("Could not find database");


$result=mysql_query("SELECT * FROM postings WHERE forumid='$forumid' && replyto=0 ") ;
if(mysql_num_rows($result)==0)
{
dosomething....

}


it tells me that $result is not a valid MySQL result resource... But I know it is. Please help!

cneumann
12-13-2001, 05:15 AM
Hi Drake,

your SQL - Query is not valid because you should use AND insteat of &&

>> $result=mysql_query("SELECT * FROM postings WHERE forumid='$forumid' && replyto=0 ") ;

should be

$result=mysql_query("SELECT * FROM postings WHERE forumid='$forumid' and replyto=0 ") ;

Anon
12-13-2001, 06:30 AM
I guess && and AND are the same things.

Please use mysql_error to check the error.

i hope ur query fails some where

Regards
Mandar Kelkar

jrmad
12-13-2001, 05:29 PM
hi drake,

i've replay to your other posting but here is the same prob i think. so try this at home :)

<?php
$conn = @mysql_connect("127.0.0.1", "", "");
if($conn) {
mysql_select_db("NAME_OF_YOUR_DB", $conn);
}
else {
die("cant't get connection");
}
$sql = "SELECT * FROM pass where name='$username' && password='$password'";
$result= mysql_query($sql, $conn);
$test=mysql_num_rows($result);
echo $test;
?>


JR