mysql_num_rows

From: Date: Wed, 31 May 2006 04:28:28 +0000
Subject: mysql_num_rows
Groups: php.general 
Request: Send a blank email to php-general+get-237123@lists.php.net to get a copy of this message
How can I get an integer value for mysql_affected_rows()? I get text: " n Database Transfer(s)". I would like to create my own error flag and exit; if the number of affected rows is <= 0. The example for mysql-num-rows in the manual does not work. I have MySQL - 4.1.12. $num_rows = mysql_num_rows($result); echo "$num_rows Rows\n"; http://ca3.php.net/manual/en/function.mysql-num-rows.php I get: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/html2/db/tools/test.php on line 29 Rows Database Transfer Here is my code. -------------------------------------------------------------------------------- $sql ="insert into jtjohnston.ccl (RNum,YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,SR,PL,PR,JR,VNum,INum,DT,PG,LG,SF,OL,KW,AUS,TUS,GEO,AN,RB,SA,CO,RR) select RNum,YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,SR,PL,PR,JR,VNum,INum,DT,PG,LG,SF,OL,KW,AUS,TUS,GEO,AN,RB,SA, CONCAT(CO,' <Transfered: ".date("F jS, Y, g:i a").">;'),RR FROM ".$_POST["dbtable"]." WHERE id=".$_POST["transferthis"].";"; echo "<pre>".htmlspecialchars($sql)."</pre><hr size=\"1\">\n"; $myconnection = mysql_connect($server,$user,$pass); mysql_select_db($db,$myconnection); $result = mysql_query($sql) or die(print mysql_error()); echo mysql_affected_rows(); #$num_rows = mysql_num_rows($result); #echo "$num_rows Rows\n";

« previous php.general (#237123) next »