will_1990 Posted March 5, 2009 Share Posted March 5, 2009 I have a three queries that are running but the 2nd one is not updating a dateback fie;d but the next part which inserts a new row in the same table. can anyone see what the problem could be? thanks! //query $q1 = ("SELECT BcId, BorId, DateOut from Loan WHERE BcId = '$bcid' AND BorId ='$bid' AND DateOut ='$do'"); $res1 = mysql_query($q1) or die (mysql_error()); if ($res1){ [b] $q2 = ("UPDATE Loan SET DateBack = CURDATE() WHERE BcId = '$bcid' AND BorId = '$bid' AND DateOut ='$do'"); $res2 = mysql_query($q2) or die (mysql_error()); }[/b] if ($res2) { //If it ran ok. $q3 = "INSERT INTO Loan (BorId, BcId, DateOut, DateDue, DateBack) VALUES ('$bid', '$bcid', CURDATE() , ADDDATE(CURDATE(), INTERVAL 2 MONTH), NULL)"; $res3 = mysql_query($q3) or die (mysql_error());} // Print message below: if ($res3) { $q2 = ("UPDATE Loan SET DateBack = CURDATE() WHERE BcId = '$bcid' AND BorId = '$bid' AND DateOut ='$do'"); $res2 = mysql_query($q2) or die (mysql_error()); } if ($res2) { //If it ran ok. - this is the one not updating correctly! thanks! Quote Link to comment Share on other sites More sharing options...
phpdragon Posted March 5, 2009 Share Posted March 5, 2009 declare those functions as variables then insert the variables into the database also you are stating that you want to insert 5 feilds of data then you declare 6 feilds of data in the values, the number declared to be inserted must equal the number of feilds in the values. 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.