RE: [PHP] What am I doing wrong?
| From: | David Stoltz | Date: | Fri, 17 Apr 2009 16:21:57 +0000 |
| Subject: | RE: [PHP] What am I doing wrong? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-291641@lists.php.net to get a copy of this message | ||
Thanks - actually, as I just figured out, there were PHP errors, but I
never saw them because of the redirection header at the end...
If I comment that out, I see that I didn't have execute permissions on
the SP....
Thanks for the help!
-----Original Message-----
From: Jay Blanchard [mailto:jblanchard@pocket.com]
Sent: Friday, April 17, 2009 12:17 PM
To: David Stoltz; php-general@lists.php.net
Subject: RE: [PHP] What am I doing wrong?
[snip]
I can't seem to understand PHP error trapping...I have it turned on in
php.ini, and on the page in question, I have "error_reporting(E_ALL);"
on the page in question below - the following code does NOT generate any
errors, but it doesn't perform the insert either....the stored procedure
exists, but even if I purposely misspell the stored procedure name, no
errors are raised...any advice?
<?php
error_reporting(E_ALL);
//submit the request
//write entry into database
$fname = $_POST[fname];
$lname = $_POST[lname];
$dept = $_POST[dept];
$phone = $_POST[phone];
$super = $_POST[super];
$groups = $_POST[groups];
//Assign the server connection to a variable
$connect = mssql_connect('SERVERNAME,1433', 'username', 'password');
//Select your database and reference the connection
mssql_select_db('DBName', $connect);
// Create a new stored prodecure
$stmt = mssql_init('sp_name');
// Bind the field names
mssql_bind($stmt, '@fname',$fname,SQLVARCHAR,false,false,25);
mssql_bind($stmt, '@lname',$lname,SQLVARCHAR,false,false,25);
mssql_bind($stmt, '@dept',$dept,SQLVARCHAR,false,false,50);
mssql_bind($stmt, '@phone',$phone,SQLVARCHAR,false,false,25);
mssql_bind($stmt, '@super',$super,SQLVARCHAR,false,false,50);
mssql_bind($stmt, '@groups',$groups,SQLVARCHAR,false,false,8000);
// Execute
mssql_execute($stmt);
header("Location: done.php");
exit;
?>
[/snip]
No PHP error occurs that is why you do not get an error. Insert this
http://us.php.net/manual/en/function.mssql-get-last-message.php
after the execute and you should get a message back from SQL Server