I have a PHP form that adds data to a MySQL DB, I now have to convert that PHP code so that it will work on a MSSQL DB. PHP is running fine on the server.
Here’s what I have so far, basically I changed everything that WAS mysql_ to mssql_ but it’s not working. I have a line that I’m not showing that calls a config file that connects to the DB as well, I’m also not showing the HTML form unless you need it.
<?php
if (isset($_POST['vendor_id'])) { //Check for a field that is mandatory to do the inserted
$vendor = mssql_escape_string($_POST['vendor_id']);
$name = mssql_escape_string($_POST['name_id']);
$version = mssql_escape_string($_POST['version']);
$serial = (!empty($_POST['serial'])) ? $_POST['serial'] : 'NULL';
$productkey = (!empty($_POST['productkey'])) ? $_POST['productkey'] : 'NULL';
$department = mssql_escape_string($_POST['department']);
$owner = mssql_escape_string($_POST['owner']);
$computer = (!empty($_POST['computer'])) ? $_POST['computer'] : 'NULL';
$comments = (!empty($_POST['comments'])) ? $_POST['comments'] : 'NULL';
$acquired = (!empty($_POST['acquired'])) ? $_POST['acquired'] : 'NULL';
$retired = mssql_escape_string($_POST['retired']);
$sql = "INSERT INTO dbo.keylist_detail (vendor_id,name_id,version,Serial,ProductKey,department_ID,owner,computer,Comments,acquired,retired)
VALUES (''$vendor','$name','$version',$serial','$productkey','$department','$owner','$computer','$comments','$acquired','$retired'')";
mssql_query($SQL);
if (mssql_query($sql)) {
echo '<strong><em>Your data has been submitted</em></strong><br /><br />';
} else {
echo '<p>Error adding submitted info: ' . mssql_error(). '</p>';
}
}
?>