Wednesday 9 January 2019

sql server - how to alter table in ms sql server2014 using php

error I am using ms sql database for the first time and I am trying to make an update on the table using php. these are the codes that I used for the update. it says there's an error "Undefined index: cust_id "




$serverName = "kwe-PC\SQLEXPRESS";
$connectionInfo = array("Database" => "customerdb", "UID" => "dbadmin", "PWD" => "kwe");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn === false) {
die(print_r(sqlsrv_errors(), true));

}
//declare the SQL statement that will query the database
$query = "SELECT * FROM Customer_Details WHERE Rec_No=".$_POST['id'];

//execute the SQL query and return records
$result = sqlsrv_query($conn, $query)
or die(print_r(sqlsrv_errors(), true));
//Show results in table

$o = '';

while ($record = sqlsrv_fetch_array($result)) {
$street1 = $record['street'];
$o .='';
$o .= '';
$o .= '';
$o .= '';
$o .="";
$o .= '';
$o .= '';
/*$o .='';*/

$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';

$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';

$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
$o .='';
}


$o .= '
REC NO.: CUSTOMER ID:
CUSTOMER NAME: SEC-REGISTERED NAME:
TIN NUMBER: STORE TYPE:
ORGANIZATION AND BUSINESS:
SIZE OF BUSINESS: SELLER ID:
DATE OF ESTABLISHMENT:
' . date('F d, Y', strtotime($record ['Date of Establishment'])) . '
ADDRESS(Headquarters):
 
TELEPHONE# / FAX: PAYMENT TERMS:
SHIPPING INSTRUCTIONS:
NUMBER OF DOORS: NUMBER OF WAREHOUSES:
CONTACT PERSONNEL:
OWNER:
PURCHASER/S:
ACCOUNTING HEAD:
WAREHOUSE HEAD:
OTHER PERSONNEL:
TERMS AND DISCOUNTS:
PAYMENT TERMS: COLLECTION SCHEDULE:
DISCOUNT:
BUSINESS GOALS:
VOLUME:CSL:
MERCHANDISING:ASSORTMENT:
VEHICLE:PRICING:
DISTRIBUTION:MARGIN:
STRATEGIES:
PRICE:PEOPLE:
PROMOTION:PRODUCT:
CATMAN ENROLLMENT:
POLICIES:
REPLENISHMENT ORDERS:
ASSORTMENT/MERCHANDISING:
NEW PRODUCTS:
PRICING/PROMOTION:
UPLOAD PICTURE:
';
echo $o;
echo"";

echo"
";
$serverName = "kwe-PC\SQLEXPRESS";
$connectionInfo = array("Database" => "customerdb", "UID" => "dbadmin", "PWD" => "kwe");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn === false) {

die(print_r(sqlsrv_errors(), true));
}
if (isset($_POST['submit'])) {
$sql = "UPDATE Customer_Details SET Cust_ID = ".$_POST['cust_id']." WHERE Rec_No =" . $_POST['id'];
sqlsrv_query($conn, $sql);
$ids = $_POST['id'];

}
else{
echo "ID is empty";

}
?>


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...