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>
PHP and mssql_query() - Internal Server 500 Error
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: PHP and mssql_query() - Internal Server 500 Error
First off I don't have any idea what the <SCRIPT LANGUAGE = "PHP"> is. Second, you either need to escape the double-quotes in your query, or use single-quotes.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: PHP and mssql_query() - Internal Server 500 Error
AbraCadaver wrote:First off I don't have any idea what the <SCRIPT LANGUAGE = "PHP"> is. Second, you either need to escape the double-quotes in your query, or use single-quotes.
<SCRIPT LANGUAGE = "PHP"> is just another way to "open" a PHP script. I found it years ago and been using it ever since.
Can you clarify your second comment? I'm a wee bit confused. Sorry
Re: PHP and mssql_query() - Internal Server 500 Error
mjkomidar wrote:AbraCadaver wrote:First off I don't have any idea what the <SCRIPT LANGUAGE = "PHP"> is. Second, you either need to escape the double-quotes in your query, or use single-quotes.
<SCRIPT LANGUAGE = "PHP"> is just another way to "open" a PHP script. I found it years ago and been using it ever since.
Can you clarify your second comment? I'm a wee bit confused. SorryI'm just a little rusty in certain areas. Thanks!
I may have figured it out. I just replaced the " with ' and didn't get the 500 error. Now I recieved a different error that I need to work on. LOL, I can't believe I didn't notice it. I've been staring at the code for days. Thanks for the help!