Jump to content

3 part query not failing!


will_1990

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/148036-3-part-query-not-failing/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.