Misty Corning
asked on
Submitting a PHP form to SQL Server
Hello, when submitting my form, I get the following error:
Fatal error: Uncaught Error: Call to undefined function odbc_execute() in C:\xampp\htdocs\test\pagea .php:87 Stack trace: #0 {main} thrown in C:\xampp\htdocs\test\pagea .php on line 87
Thanks in advance!
pagea.php
Fatal error: Uncaught Error: Call to undefined function odbc_execute() in C:\xampp\htdocs\test\pagea
Thanks in advance!
pagea.php
Can you please share pagea.php
ASKER
Should be there now. Thanks
ASKER
Create a sample file that contains:
<?php phpinfo();
If you do not see the odbc extension loaded you will need to load it in your php.ini for support.
<?php phpinfo();
If you do not see the odbc extension loaded you will need to load it in your php.ini for support.
ASKER
ok, viewing it now. What heading is it under?
In chrome click control F and search the page for: odbc
The documentation says that this line needs to be in the php.ini:
extension=php_odbc.dll
extension=php_odbc.dll
ASKER
there are already drivers: odbc 11 for SQL Server and odbc 17 for SQL Server. I'm running 7.1 on windows server 2012 r 2. Which one do I need?
Do I add these to my php.ini as well?
Do I add these to my php.ini as well?
ASKER
Which one do I need in my connection string?
ASKER
now it says expects parameter 1 to be resource, null given
$sql=odbc_exec($conn, "INSERT INTO SBLAND values ('$badgenumber','$officer' ,getdate() ,'$gender' ,'$race',' $raceknown prior', '$reasonforstop','$locatio n','$searc hconducted ','$reason forsearch' ,'$contrab and','$des criptionof contraband ','$arrest ed', '$offensecharged','$arrest number','$ forceused' ,'$bodilyi njury','$v erbalwarni ng','$writ tencitatio n', '$citationnumber', '$writtenwarning','$warnin gnumber',' $writtenfi eld')");
$sql=odbc_exec($conn, "INSERT INTO SBLAND values ('$badgenumber','$officer'
That is because the $conn variable is not a valid connection. In your
You need to setup error reporting around your DB Connection and
a) Check to see that a valid connection is made
b) If it fails report an error so you can see why.
For now you need to go back to your connection.inc.php file and see what connection parameters you are using and check that they are correct. Additionally, put some error output (odbc-errormsg so you can get some idea of what went wrong.
include_once('connection.inc.php');
The connection to the database failed.You need to setup error reporting around your DB Connection and
a) Check to see that a valid connection is made
b) If it fails report an error so you can see why.
For now you need to go back to your connection.inc.php file and see what connection parameters you are using and check that they are correct. Additionally, put some error output (odbc-errormsg so you can get some idea of what went wrong.
ASKER
I did that. In this file, it shows its connected. Is this giving a false reading?
connection.inc.php
connection.inc.php
Firstly your connection.inc.php is not constructed correctly. It is constructed as if it were a page rather than a utility script you are including.
Included scripts don't have the <html> and body tags. In this case I would make it pure PHP - no html.
Secondly, the error you are getting suggests the connection failed - but that does not make sense because the die() statement in the connection.inc.php file should have caught that so unless there is something you have not shown us it does not make sense.
Included scripts don't have the <html> and body tags. In this case I would make it pure PHP - no html.
Secondly, the error you are getting suggests the connection failed - but that does not make sense because the die() statement in the connection.inc.php file should have caught that so unless there is something you have not shown us it does not make sense.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.