Problem inserting into MSSQL using PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gtcol
Forum Newbie
Posts: 20
Joined: Mon May 28, 2007 10:15 am
Contact:

Problem inserting into MSSQL using PHP

Post by gtcol »

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]:

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");
}
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The query you're creating is never used in this snippet. I see you're developing with E_NOTICE off too, tsk tsk. ;)
gtcol
Forum Newbie
Posts: 20
Joined: Mon May 28, 2007 10:15 am
Contact:

Problem inserting into MSSQL using PHP

Post by gtcol »

Hello,
I am really sorry for taking your valuable time. ( and Space :wink: )
Gawwwwd. I don't believe this.
Anyways,
Sincere Thanks to Feyd.
gtcol
Post Reply