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
MySQL Error
Moderator: General Moderators
-
manojsemwal1
- Forum Contributor
- Posts: 217
- Joined: Mon Jun 29, 2009 4:13 am
- Location: India
Re: MySQL Error
mysql_num_rows is only good for SELECT queries. You want mysql_affected_rows.
-
manojsemwal1
- Forum Contributor
- Posts: 217
- Joined: Mon Jun 29, 2009 4:13 am
- Location: India
Re: MySQL Error
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
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
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)
-
manojsemwal1
- Forum Contributor
- Posts: 217
- Joined: Mon Jun 29, 2009 4:13 am
- Location: India
Re: MySQL Error
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
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
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.
-
manojsemwal1
- Forum Contributor
- Posts: 217
- Joined: Mon Jun 29, 2009 4:13 am
- Location: India
Re: MySQL Error
Thanks For your valuable reply ...................
thank you very much....................
thank you very much....................