Problem inserting into MSSQL using PHP
Posted: Tue Jun 26, 2007 7:12 am
Hi all,
I got a strange problem here. When I do an insert from my app, i get the msg that the data is inserted and also when I echoed all the vars, it displayed all var values. But when i go to the MSSQL Query Analyzer and run the select statement, it doesn't display the record that i just inserted. Tried this several times, but the same result. I can insert data from MSSQL Query Analyzer.
Its driving me crazy as I can't see anything wrong with the script. Is there any tweak I need to work on or anything that I am just overlooking. Please suggest. I appreicate your help or any suggestion.
This is the script [FYI]:
I got a strange problem here. When I do an insert from my app, i get the msg that the data is inserted and also when I echoed all the vars, it displayed all var values. But when i go to the MSSQL Query Analyzer and run the select statement, it doesn't display the record that i just inserted. Tried this several times, but the same result. I can insert data from MSSQL Query Analyzer.
Its driving me crazy as I can't see anything wrong with the script. Is there any tweak I need to work on or anything that I am just overlooking. Please suggest. I appreicate your help or any suggestion.
This is the script [FYI]:
Code: Select all
<?php
$Added = 0;
if (isset($_POST['action']) && $_POST['action'] == 'submitted') {
$ContNo = $_POST[cno]; $BlNo = $_POST[blno]; $TrNo = $_POST[trno]; $Tc = $_POST[tc]; $SizeTyp = $_POST[sizetype];
$SNo = $_POST[sno]; $SCo = $_POST[sco]; $SType = $_POST[stype]; $StType = $_POST[st_type]; $Sddc = $_POST[sddc];
$Cmt = $_POST[cmt]; $Adt = $_POST[adt]; $Udt = $_POST[udt]; $Pld = $_POST[pld]; $Status = $_POST[status];
$Connection = mssql_connect('gt-lap', 'sa', 'sa') or die ("Could not connect to the server");
$Db = mssql_select_db("testCon", $Connection) or die ("Could not connect to the database");
$Sql = "insert into tbl_ContainerDetails (ContNo,TruckRego,BLNo,TempClass,Sizetype,Sealno,ShippingCo,Type,";
$Sql.= "StockType,SDDC,Comments,ArrivalDt,UnloadDt,DepartureDt,PresentLoc) VALUES ('$ContNo','$TrNo','$BlNo','$Tc','$SizeTyp','$SNo','$SCo',";
$Sql.= "'$SType','$StType','$Sddc','$Cmt','$Adt','$Udt','$Pld','$Status')";
echo "Data about $ContNo inserted";
echo "'$ContNo','$TrNo','$BlNo','$Tc','$SizeTyp','$SNo','$SCo','$SType','$StType','$Sddc','$Cmt','$Adt','$Udt','$Pld','$Status'";
$Added = 1;
$Msg = "Your data has been successfully added.";
include("con_details.htm");
//include("con_details_confirm.htm");
} else {
$Added = 0;
include("con_details.htm");
}
?>