darkfreaks Posted February 11, 2008 Share Posted February 11, 2008 can anyone get this one ??? <?php $query = "INSERT INTO `vc_covenmembers` (`username`,`date`,`covenname`,`approvalreason`,`approved`) VALUES('{$username}','{$date}','{$covenname}','{$approvalreason}','{$approved}')"; $result=mysql_query($query) or die(mysql_error()); $num=mysql_num_rows($result); if($num=>0){ echo"You are already a Member of $covenname"; } ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted February 11, 2008 Share Posted February 11, 2008 Your query is failing. Quote Link to comment Share on other sites More sharing options...
Barand Posted February 11, 2008 Share Posted February 11, 2008 RTFM mysql_num_rows (PHP 3, PHP 4, PHP 5) mysql_num_rows -- Get number of rows in result Description int mysql_num_rows ( resource result ) Retrieves the number of rows from a result set. This command is only valid for SELECT statements. To retrieve the number of rows affected by a INSERT, UPDATE, or DELETE query, use mysql_affected_rows(). Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted February 11, 2008 Share Posted February 11, 2008 logically a num_rows doesn't make sense on an insert. Yes it should return a single affect row on success, but if you have the or die(mysql_error()."<Br /><br />".$q); then it dies if the query fails. If you want to test that the user name isn't already used run a select first and then get the num rows off that. Num_rows is only really useful on updates selects and deletes Quote Link to comment Share on other sites More sharing options...
Barand Posted February 11, 2008 Share Posted February 11, 2008 logically a num_rows doesn't make sense on an insert. Yes it should return a single affect row on success, but if you have the or die(mysql_error()."<Br /><br />".$q); then it dies if the query fails. Num_rows is only really useful on updates selects and deletes As the manual states (read my previous post) num_rows is only for select statements. Affected_rows is for queries that do not return a result set (insert, update, delete) And ALL of them can affect multiple rows. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.