PHP and mssql_query() - Internal Server 500 Error
Posted: Wed Dec 30, 2009 10:06 am
This is my first time using MSSQL with PHP and I have having an issue that I can't solve (I have used MySQL for years with no problems).
When I run the following script, I get a generic Internal Server 500 Error with no explanation. I ran another script to test the $_POST variables to make sure they get passed and that worked fine. Also, In other tests my db connection and db selection work just fine. Could there be an issue with my INSERT or mssql_query() statement?
<SCRIPT LANGUAGE = "PHP">
$server = '****';
$connect = mssql_connect($server, 'sa', '****');
mssql_select_db('db_jobs', $connect);
$sql = "INSERT INTO tbl_jobs
(
job_company,
job_location,
job_title,
job_desc,
job_exper,
job_edu,
job_link
)
VALUES
(
$_POST["company"],
$_POST["location"],
$_POST["title"],
$_POST["desc"],
$_POST["exper"],
$_POST["edu"],
$_POST["link"]
)";
$query = mssql_query($sql);
if(!$connect)
{
die('Something went wrong while connecting to MSSQL');
}
if(!$query)
{
die('Something went wrong while inserting data into the table');
}
</SCRIPT>
When I run the following script, I get a generic Internal Server 500 Error with no explanation. I ran another script to test the $_POST variables to make sure they get passed and that worked fine. Also, In other tests my db connection and db selection work just fine. Could there be an issue with my INSERT or mssql_query() statement?
<SCRIPT LANGUAGE = "PHP">
$server = '****';
$connect = mssql_connect($server, 'sa', '****');
mssql_select_db('db_jobs', $connect);
$sql = "INSERT INTO tbl_jobs
(
job_company,
job_location,
job_title,
job_desc,
job_exper,
job_edu,
job_link
)
VALUES
(
$_POST["company"],
$_POST["location"],
$_POST["title"],
$_POST["desc"],
$_POST["exper"],
$_POST["edu"],
$_POST["link"]
)";
$query = mssql_query($sql);
if(!$connect)
{
die('Something went wrong while connecting to MSSQL');
}
if(!$query)
{
die('Something went wrong while inserting data into the table');
}
</SCRIPT>