Insert data into mssql database

A

Anonymous

Guest
I am having problems inserting data into a mssql database,

I have the connection working fine as I can read and output data ok, but when I am trying to insert data using a form I get the following error:

Fatal error: Call to undefined function mssql_query() in D:\Apache2\htdocs\processcall.php on line 13

if possible can someone help me with the code!! :?

Code:
<?
require_once('./odbccon.php');
$name = $_POST['requestor'];
$tsk = $_POST['task'];
$dsc = $_POST['description'];

$insert = "Insert into tasks (REQUEST,TASK,DESCRIPT) values ('$name','$tsk','$dsc')";

mssql_query($insert) or die('Unable to log call');
?>
 
dashwood75 said:
I am having problems inserting data into a mssql database,

I have the connection working fine as I can read and output data ok, but when I am trying to insert data using a form I get the following error:

Fatal error: Call to undefined function mssql_query() in D:\Apache2\htdocs\processcall.php on line 13

if possible can someone help me with the code!! :?

Code:
<?
require_once('./odbccon.php');
$name = $_POST['requestor'];
$tsk = $_POST['task'];
$dsc = $_POST['description'];

$insert = "Insert into tasks (REQUEST,TASK,DESCRIPT) values ('$name','$tsk','$dsc')";

mssql_query($insert) or die('Unable to log call');
?>
be sure what MS SQL library is ON (php.ini). By default all additional library is disabled.
Code:
<?php
phpinfo();
?
see inside.
 
I have enabled the mssql libraries, which I should have realised as I had to enable the mysql ones when I setup my php install!!

but alas I am still having problems.

the error code has changed to this:

Warning: mssql_query(): supplied resource is not a valid MS SQL-Link resource in D:\Apache2\htdocs\processcall.php on line 15

this is the line it is referencing:

Code:
<?
mssql_query($insert,$connectionstring)or die('Unable to log call');
>?

the $insert is my sql statement, and the $connectionstring is my connection information.

if anyone can help correct my code it is appreciated!!

:help:
 
dashwood75 said:
I have enabled the mssql libraries, which I should have realised as I had to enable the mysql ones when I setup my php install!!

but alas I am still having problems.

the error code has changed to this:

Warning: mssql_query(): supplied resource is not a valid MS SQL-Link resource in D:\Apache2\htdocs\processcall.php on line 15

this is the line it is referencing:

Code:
<?
mssql_query($insert,$connectionstring)or die('Unable to log call');
>?

the $insert is my sql statement, and the $connectionstring is my connection information.

if anyone can help correct my code it is appreciated!!

:help:
This error tell you what somthing incorrect.

be sure what:
1) connection is present
2) query is correct
3) query return true

If you are trying put info in table what not exist see 2
are you sure what your tables is uppercased?

try table field put in quotes like:
$insert = "insert into tasks (`REQUEST`,`TASK`,`DESCRIPT`) values (`$name`,`$tsk`,`$dsc`)";
 
be sure you specify the port as well 1433 when connecting the DB
Code:
<?php
$conn = mssql_connect('server,1433', 'username', 'password'); // If your OS(web server) is windows
$conn = mssql_connect('server:1433', 'username', 'password'); // If your OS(web server) is linux
?>
 
Cheers for the advice, but in the end opted to do it a different way by using form to email submission, which now works a treat!

I am learning something finally!! :D
 
Back
Top