Page 1 of 1

MySQL Error

Posted: Wed Jan 20, 2010 4:22 am
by manojsemwal1
Hai Iam facing a problem with this mysql query ............

$sqlinsert="insert into quitstudents value('$regdid','$subjectid','$remarks','L','$cdate')";
echo $sqlinsert;
$rs=mysql_query($sqlinsert) or die("Error: ". mysql_error(). " with query ". $sqlinsert);
$countinsert=mysql_num_rows($sqlinsert);


data is insert into database but giving error.
insert into quitstudents value('8009','4','fgf','L','2010-01-20')
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/iiewscom/public_html/PHP/ClientEntry/quitstudententry.php on line 41

Re: MySQL Error

Posted: Wed Jan 20, 2010 5:33 am
by requinix
mysql_num_rows is only good for SELECT queries. You want mysql_affected_rows.

Re: MySQL Error

Posted: Wed Jan 20, 2010 6:35 am
by manojsemwal1
Thanks for your reply

its also giving same error........

Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /home/iiewscom/public_html/PHP/ClientEntry/quitstudententry.php on line 62

Re: MySQL Error

Posted: Wed Jan 20, 2010 7:33 am
by Eran
You need to put the link resource inside mysql_affected_rows, not the query itself. Just run it without parameters in the function (as a quick look in the manual link tsairis provided would have made this obvious)

Re: MySQL Error

Posted: Wed Jan 20, 2010 8:27 am
by manojsemwal1
Thanks........

ya without parameter its run fine but if we are execute more than one query than what we have to do.

like here
$sqlinsert=mysql_query("insert into quitstudents values('$regdid','$subjectid','$remarks','$cdate','L')");
$sqlregdup=mysql_query("update studentregdtb set Approval='L' where RegdId='$regdid'");

$countinsert=mysql_affected_rows();

this mysql_affected_rows() will return which query last query or frist query.

Thanks

Re: MySQL Error

Posted: Wed Jan 20, 2010 8:28 am
by Eran
It will always return a count for the last query ran with the current connection. Run it between the queries and store the results in a variable.

Re: MySQL Error

Posted: Wed Jan 20, 2010 10:46 pm
by manojsemwal1
Thanks For your valuable reply ...................


thank you very much....................