Hello,

I have a problem connecting to a DSN using odbc_connect.
The problem is no connection id is returned.
If I use :

error_reporting = E_ALL & ~(E_NOTICE | E_WARNING) in php.ini

than I get a blank page in browser.

If I don't use error_reporting = E_ALL & ~(E_NOTICE | E_WARNING)

than I get:

Warning: SQL error, SQL state 00000 in SQLconnection .... on line 2(the line with odbc_connect).

The DSN is made to an access database.
Why do I have this problem. if you need any other informations please tell me.

    15 days later

    I have the same problem! I have the same page running fine on a local webserver. but on the iis I do have this problem....
    seb

      I also have the same problem, see my message above. Can you get into the db with excel? i can and need to know why php can't

        Can you post your odbc_connect statement?

        Also, just for the sake of saying it, you did set the DSN on the server and/or were given this info?

          Originally posted by mr_zog
          Can you post your odbc_connect statement?

          Also, just for the sake of saying it, you did set the DSN on the server and/or were given this info?

          i cannot connect using the odbc_connect statement that line produces the error message

          I created the DSN locally and connected it to the db on the server using the select option. The DSN is named exactly the same as the DB without the .mdb extension

            Can you post the odbc_connect statement from your code. If it is producing an error - I just wanna double check the syntax.

            It should be

            $connect=odbc_connect("DSN","user","pass");

            with the quotes. If you do not have a pass - for example - then you would have something like this:

            $connect=odbc_connect("DSN","user","");

            Hope that may help.

              Originally posted by stevedodkins


              i cannot connect using the odbc_connect statement that line produces the error message

              I created the DSN locally and connected it to the db on the server using the select option. The DSN is named exactly the same as the DB without the .mdb extension

              Hi Mines in double quotes.

              odbc_connect( "dsn", "user", "pwd" );

                Which query are you using:

                odbc_do

                OR

                odbc_prepare
                odbc_execute

                  save your odbc as a system dsn! helped me. it does work now... do not ask why! 🙂
                  greetz seb

                    Originally posted by mr_zog
                    Which query are you using:

                    odbc_do

                    OR

                    odbc_prepare
                    odbc_execute

                    Hi

                    I'm using the odbc_exec( $link "select cust_idno, etc );
                    $link = odbc_connect( "dsn"
                    But if i copy the db to the local machine and reset the dsn file path to the local machine it works, but over the network it does not.
                    Excel can open the db over the network.
                    This is from a W2K local machine and Novell 5.1 server

                      If it works locally and not over the network then it's a security problem.

                      What user account is your webserver running as? If it's LocalSystem then that's the problem, as LocalSystem doesn't have access to network resources.

                        Originally posted by Vex
                        If it works locally and not over the network then it's a security problem.

                        What user account is your webserver running as? If it's LocalSystem then that's the problem, as LocalSystem doesn't have access to network resources.

                        Hi
                        i'm currently using apache 2, how do i set the account for the webserver?

                          On windows 2000 it's done in the services admin control (Settings->Control Panel->Administrative Controls->Services). You can specify the logon user for each service, you'll need to give Apache2 a user account that has network access.

                          On other OS I don't know.

                            Originally posted by Vex
                            On windows 2000 it's done in the services admin control (Settings->Control Panel->Administrative Controls->Services). You can specify the logon user for each service, you'll need to give Apache2 a user account that has network access.

                            On other OS I don't know.

                            Hi

                            Spot on,

                            Thanks very much for your help!

                            Steve

                              well, i have this:
                              <?php $connect = odbc_connect('DSN-name', 'Username', 'Password') or die ("unable to connect");
                              $query = "SELECT * FROM Title" ;
                              $result = odbc_exec($connect, $query);

                              while($row = odbc_fetch_array($result)) {
                              $TitleID = $row[TitleID];
                              $Title = $row[Title];
                              echo $Title; }?>

                              and the 1st part seems to work, but for the second part i get this:

                              Call to undefined function: odbc_fetch_array()

                              I am using a system dsn, so that works. ( note that you can never use a user dsn. those only respond to a user that directly opens the DB AND that user MUST be logged on/in. This does NOT apply to system DSNs)

                                Well, if you've read the comments, they say it doesn't work, and to use a different function to do your fetch.

                                Either that, or use the function given in the second comment as a work around....

                                  i think the fetch_into works, but theres this:[code]
                                  if (odbc_fetch_row($result))
                                  {while(odbc_fetch_into($result, $row, $my_array) )
                                  {echo $my_array['Title'];}}
                                  else {echo "Failed!";}[/code]
                                  this time it only gives an error on the $my_array. how do i solve this? (errormessage says it
                                  s undifined...)

                                    What version of PHP are you using?

                                      Write a Reply...