Page 1 of 1

ODBC to MS Access

Posted: Sat Dec 09, 2006 6:10 pm
by bmcellis
I have searched a couple times and have tried a couple online examples but I can not for the life get PHP to write to an MS Access db via ODBC.

I have Apache and PHP installed and both appear to be running properly. I used PHPBuilder.com and the example at W3Schools literally making the system dsn and the same db that they describe but I can not for the life of me get the form to write to the tables. The forms I created show up just fine the data is just not stored properly.

I'm getting no error messages and after I use the submit button I do get to the page that is supposed to be writing to the db but no data gets saved.

Is there a thread already somewhere that discusses this?

Suggestions? :(

Posted: Sat Dec 09, 2006 6:12 pm
by feyd
It may be a good idea to post your existing code and versions of the components involved (e.g. PHP, Access, etc)

ODBC to MS Access

Posted: Sun Dec 10, 2006 12:36 pm
by bmcellis
This is the tutorial that I used on my work machine.

Haven't tried it on the home machine yet.

http://www.phpbuilder.com/columns/siddarth20000228.php3

I used the more current versions of PHP though. Step 3 is giving me an error on my home machine which didn't give me an error on my work machine. Maybe there is something wrong with there example and there's a better example elsewhere?

Becky

blank page update

Posted: Mon Dec 11, 2006 12:24 pm
by bmcellis
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Actually things as simple as this are giving me blank pages.

It appears my services are working and I see a system dsn created.  This is a sample from a web page that I tried to recreate but I can't remember which one right now.

Becky

Code: Select all

<html>
<head></head>

<body>

<? php
# connect to a DSN "my_db" with a user and password "marin" 
$connect = odbc_connect("my_db", "becky", "tigger");

# query the users table for name and surname 
$query = "SELECT name, surname FROM people";
echo $query;

# perform the query 
$result = odbc_exec($connect, $query);

# fetch the data from the database 
while(odbc_fetch_row($result))  { $name = odbc_result($result, 1); $surname = odbc_result($result, 2); print("$name $surname\n"); }

# close the connection 
odbc_close($connect); ?> 

</body>
</html>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]