Could anyone please help me with this?I want to find a solution for the code pasted and the problem explained below.
session_start();
if ($randval) {
$app_Date= date("Y-m-d");
$app_Time = date("g:i:s");
// database connection
$connection = mysql_connect("192.168.0.4", "root", "") or die ("Couldn't connect to server.");
$db = mysql_select_db("cusat", $connection) or die ("Couldn't select database.");
//Data Update to registration table
$lock_table= "LOCK TABLES registration WRITE";
$result = mysql_query($lock_table) or die("Couldn't lock the table.");
$sql = "UPDATE registration set title=\"$title\", displyName=\"$displyName\", gender=\"$gender\", department=\"$department\" , institution=\"$institution\" , address=\"$address\" , city=\"$city\" , zip=\"$zip\" , country=\"$country\" , phone=\"$phone\" , fax=\"$fax\", password=\"$password\", nationality=\"$nationality\", passportNo=\"$passportNo\", dateOfIssue=\"$dateOfIssue\", placeOfIssue=\"$placeOfIssue\", validUpto=\"$validUpto\", visaIssuingCity=\"$visaIssuingCity\", accomodation=\"$accomodation\", foodPreference=\"$foodPreference\", arrivalDate=\"$arrivalDate\", arrivalTime=\"$arrivalTime\", AairRailStation=\"$AairRailStation\", AflightTrainDetails=\"$AflightTrainDetails\", departureDate=\"$departureDate\", departureTime=\"$departureTime\", DairRailStation=\"$DairRailStation\", DflightTrainDetails=\"$DflightTrainDetails\", registerAs=\"$registerAs\", regular=\"$regular\",presentingPaper=\"$presentingPaper\", abstractID=\"$abstractID\", registerFor=\"$registerFor\", morningSession=\"$morningSession\", afternoonSession=\"$afternoonSession\", payment=\"$payment\", registrationFee=\"$registrationFee\", tutorialFee=\"$tutorialFee\", totalAmount=\"$totalAmount\", modeOfPayment=\"$modeOfPayment\", ddNo=\"$ddNo\", bankDetails=\"$bankDetails\" , information=\"$information\"WHERE userID= \"$userID\"" ;
$result = mysql_query($sql) or die("Couldn't update Information.");
$lock_table= "UNLOCK TABLES";
$result = mysql_query($lock_table) or die("Couldn't unlock the table.");
//Data Update to academic table
$sql = "SELECT FROM academic WHERE userID='$userID' ";
$result = mysql_query($sql) or die("Couldn't execute academic query.");
$r_num = mysql_numrows($result);
if (($r_num == 1))
{
$sql = "INSERT INTO academic VALUES (\"$userID\", \"$abstractID\", \"$paperTitle\", \"$paperStatus\", \"$mode\", \"$updatedBy\", \"$app_Date\", \"$app_Time\")" ;
$result = mysql_query($sql) or die("Couldn't register academic");
}
else
{
$lock_table= "LOCK TABLES academic WRITE";
$result = mysql_query($lock_table) or die("Couldn't lock the table.");
$sql = "UPDATE academic set abstractID=\"$abstractID\", paperTitle=\"$paperTitle\", paperStatus=\"$paperStatus\" , modeOfPresentation=\"$mode\" ,acceptedBy=\"$updatedBy\" , date=\"$app_Date\" , time=\"$app_Time\" WHERE userID= \"$userID\"" ;
$lock_table= "UNLOCK TABLES";
$result = mysql_query($sql) or die("Couldn't update academic Information.");
}
//Data Update to accomodation table
$sql = "SELECT FROM accomodation WHERE userID='$userID' ";
$result = mysql_query($sql) or die("Couldn't execute accomodation query.");
$r_num = mysql_numrows($result);
if (($r_num == 0))
{
$sql = "INSERT INTO accomodation VALUES (\"$userID\", \"$hotel\", \"$hotelName\", \"$roomNo\", \"$updatedBy\", \"$app_Date\", \"$app_Time\")" ;
$result = mysql_query($sql) or die("Couldn't register accomodation");
}
else
{
$lock_table= "LOCK TABLES accomodation WRITE";
$result = mysql_query($lock_table) or die("Couldn't lock the table.");
$sql = "UPDATE accomodation set hotel=\"$hotel\", hotelName=\"$hotelName\", roomNo=\"$roomNo\" , updatedBy=\"$updatedBy\" , date=\"$app_Date\" , time=\"$app_Time\" WHERE userID= \"$userID\"" ;
$lock_table= "UNLOCK TABLES";
$result = mysql_query($sql) or die("Couldn't update accomodation Information.");
}
//Data Update to finance table
$sql = "SELECT * FROM finance WHERE userID='$userID' ";
$result = mysql_query($sql) or die("Couldn't execute finance query.");
$r_num = mysql_numrows($result);
if (($r_num == 0))
{
$sql = "INSERT INTO finance VALUES (\"$userID\", \"$amtReceived\", \"$updatedBy\", \"$app_Date\", \"$app_Time\", \"$remarks\")" ;
$result = mysql_query($sql) or die("Couldn't register finance");
}
else
{
$lock_table= "LOCK TABLES finance WRITE";
$result = mysql_query($lock_table) or die("Couldn't lock the table.");
$sql = "UPDATE finance set amountReceived=\"$amtReceived\", updatedBy=\"$updatedBy\" , date=\"$app_Date\" , time=\"$app_Time\" , remarks=\"$remarks\" WHERE userID= \"$userID\"" ;
$lock_table= "UNLOCK TABLES";
$result = mysql_query($sql) or die("Couldn't update finance Information.");
}
Header("Location: update_admin_succ.php");
mysql_close($connection);
}
?>
Here updation in multiple tables is not working.When we update the tables,accomodation,academic,fincance separately,it is working fine.but when try to update together only one table updaton s taking place.But multiple insertion is working well.
can anyone pls help with this?urgent!!!