|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi ,
I am trying to connect Ms Access database using PHP. I am running Apache on my computer. I created DSN for MSAccess. but for odbc_connect() function I am getting this error. "SQL error: , SQL state 00000 in SQLConnect...\...\databaseconn.php line 3" what could be the reason..? |
|
#2
|
|||
|
|||
|
Which version of PHP are you using?
Which OS is PHP running on? Have you setup your php.ini file correctly ?
__________________
El éxito consiste en una serie de pequeñas victorias día a día MySQL, MS SQL, MS ACCESS, Oracle Database Manager - http://victorpendleton.net/products/psdviewer.html |
|
#3
|
|||
|
|||
|
Yeah,
I have windows 2000 OS. my php version is 4.0. I already configured my php.ini file. and rest of the things are working fine. The only problem is with Access connection. its not executing my odbc_exec() function. ![]() |
|
#4
|
|||
|
|||
|
Can you verify that you are creating a valid MySQL resouce link from odbc_connect() function?
|
|
#5
|
|||
|
|||
|
Ok ...here is what i m trying to do.
<? $connect = odbc_connect("prod","","") // "prod" is my DSN name // I am trying to connect MSAccess database using PHP and i have apache running on my computer. $query = "select * from blah_blah"; $result = odbc_exec($connect, $query); ...... the way to display the result..... ?> ...hey..wait...i just got one thought...shoudl I put my .mdb file in apache's htdocs/ ? I dont think so...right..? i can put it in my c:/ because i have already created DSN to connect with DB. anyway...thats what i m trying to do..but i am getting that error. any idea...? |
|
#6
|
|||
|
|||
|
Verify that you have a valid connection by returning the value of `$connect`. This check just ensures that the connection was successful.
|
|
#7
|
|||
|
|||
|
the error comes at the first line of my code. and it is.. at
$connect = odbc_connect("prod","",""); "SQL error: , SQL state 00000 in SQLConnect...\...\databaseconn.php line 3" so How can I print the result for $connect. ? |
|
#8
|
|||
|
|||
|
Can you try this?
$link_id = @odbc_connect("prod","","") or die ("Unable to connect to server"); print $link_id; |
|
#9
|
|||
|
|||
|
yeah,
It says....Unable to connect to server. ... I am too much frustrated now.here is my whole code.. <? // This is the DSN we have created for our database $connect = @odbc_connect('prod', '', '') or die("Unable to connect"); echo "<br>".$connect."<br>"; ?> <HTML> <BODY> Database connection testing..... <BR> <? global $connect; $noderesult = odbc_exec($connect,"select Unit_id, Unit_Name from Mfg_Units"); echo "<UL type='disc'>"; while(odbc_fetch_row($noderesult)) { $id = odbc_result($noderesult,"Unit_id"); $type = odbc_result($noderesult,"Unit_Name"); echo "<LI>"; echo "<b>$id</b> --- $type"; } echo "</UL>"; ?> </BODY> </HTML> |
|
#10
|
||||
|
||||
|
Ok, a couple of questions.
1) Are you sure the mdb file was registered as a datasource? i.e. can you open back up the odbc manager and see the file as a "system" dsn (which it must be registered as system and not user). 2) has the file been moved? 3) can you still open the file? 4) is it password protected? I just registered one on my system and accessed it just fine using the same connect statement that you did, so the syntax is correct. |
|
#11
|
|||
|
|||
|
yeah datasource is correct and it is "System" DSN only. even .mdb is also fine and working perfect in Access environment. I have one doubt ...do I have to modify something in php.ini file.? or is this related to some server configuration..?
|
|
#12
|
|||
|
|||
|
hey hey....
I got it...its working now. Thanks a lot. I just re created my system DSN and now its working perfectly. |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > PHP - MSAccess Connection. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|