mohan singh
asked on
ODBC- stored procedure in php
I have stored procedure function in mssql server
Now I need to use that stored procedure in php to insert data in database so
my question
is this possible stored procedure in Php with odbc connection ?
if yes so please tell me how to insert data
Thank You
Mohan Singh
Now I need to use that stored procedure in php to insert data in database so
my question
is this possible stored procedure in Php with odbc connection ?
if yes so please tell me how to insert data
Thank You
Mohan Singh
ASKER
Hi Raja Jegan R
but i am using odbc not sqlsrv
If you know how to insert it in database so please tell me how to call it
My stored procedure function is udp_add_update_contact it have TEN (10) parameter
Thank You
but i am using odbc not sqlsrv
If you know how to insert it in database so please tell me how to call it
My stored procedure function is udp_add_update_contact it have TEN (10) parameter
Thank You
ASKER
I am using odbc_execute Like this
odbc_execute(): SQL error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near '.'., SQL state 37000 in SQLDescribeParameter in
can you tell me what is my mistake in this code
Thank You
Mohan Singh
<?php
if(isset($_POST['signUp'])){
$f = $_POST['fname'];
$m = $_POST['mname'];
$l = $_POST['lname'];
$mo = $_POST['mobile'];
$e = $_POST['email'];
$null = "NULL";
$date = "2018-05-12";
$stmt = odbc_prepare($conn, 'CALL [dbo].[udp_add_update_contact](?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)');
$success = odbc_execute($stmt, array($null,$null,$null,$null,$f,$m,$l,$null,$mo,$null,$null,$null,$e,$null,$null,$null,$null));
}
?>
And now I am getting errorodbc_execute(): SQL error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near '.'., SQL state 37000 in SQLDescribeParameter in
can you tell me what is my mistake in this code
Thank You
Mohan Singh
I think you should add some apostrophe to your string type of value in your SQL query string variables and try.
<?php
if(isset($_POST['signUp']) ){
$f = $_POST['fname'];
$m = $_POST['mname'];
$l = $_POST['lname'];
$mo = $_POST['mobile'];
$e = $_POST['email'];
$null = "NULL";
$date = "2018-05-12";
$stmt = odbc_prepare($conn, 'CALL udp_add_update_contact(?,? ,?,?,?,?,? ,?,?,?,?,? ,?,?,?,?,? )');
$success = odbc_execute($stmt, array("NULL","NULL","NULL" ,"NULL",$f ,$m,$l,"NU LL",$mo,"N ULL","NULL ","NULL",$ e,"NULL"," NULL","NUL L","NULL") );
If above not worked try this
//$success = odbc_execute($stmt, array(NULL,NULL,NULL,NULL, $f,$m,$l,N ULL,$mo,NU LL,NULL,NU LL,$e,NULL ,NULL,NULL ,NULL));
}
?>
if(isset($_POST['signUp'])
$f = $_POST['fname'];
$m = $_POST['mname'];
$l = $_POST['lname'];
$mo = $_POST['mobile'];
$e = $_POST['email'];
$null = "NULL";
$date = "2018-05-12";
$stmt = odbc_prepare($conn, 'CALL udp_add_update_contact(?,?
$success = odbc_execute($stmt, array("NULL","NULL","NULL"
If above not worked try this
//$success = odbc_execute($stmt, array(NULL,NULL,NULL,NULL,
}
?>
ASKER
Thank you for help but your code is not working
Can you tell me what is Incorrect syntax in this line
I am getting error incorrect syntax
Thank you
Mohan Singh
Can you tell me what is Incorrect syntax in this line
[b]$stmt = odbc_prepare($conn, 'CALL [dbo].[udp_add_update_contact](?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)');[/b]
I am getting error incorrect syntax
Thank you
Mohan Singh
I think your calling syntax : [dbo].[udp_add_update_cont act]
$stmt = odbc_prepare($conn, 'CALL udp_add_update_contact(?,? ,?,?,?,?,? ,?,?,?,?,? ,?,?,?,?,? )'); this is not working? still error coming
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You Julian Hansen
For your contribution
can you explain why we need {} this bracket
For your contribution
can you explain why we need {} this bracket
ASKER
Thank you all of you
You are welcome.
The curly braces are escape characters that tell the ODBC driver to translate the contents into a native SQL call
The curly braces are escape characters that tell the ODBC driver to translate the contents into a native SQL call
http://php.net/manual/en/function.sqlsrv-execute.php