Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using PHP to connect to a foxpro database

    Hi,

    My work have given me the job of making their website connect to their accounts server which uses a foxpro free table database. Both the webserver(windows) and accounts server are on the same network, I just cant seem to get it to work, what ive done is...

    Created an ODBC connection on the webserver, connecting to accounts server.

    Put this code in a file on the webserver.

    <?php

    //connect to database
    $connectionstring = odbc_connect("Vision.dsn", "", "");

    //SQL quyery
    $Query = "SELECT * FROM CUSTOMER";

    //execute query
    $queryexe = odbc_do($connectionstring, $Query);

    //output results to standard output
    odbc_result_all($queryexe, "BORDER=1");

    //diconnect from database
    odbc_close($connectionstring);

    ?>

    And when running that script i get the error

    Warning: odbc_do() [function.odbc-do]: SQL error: [Microsoft][ODBC Visual FoxPro Driver]File 'customer.dbf' does not exist., SQL state S0002 in SQLExecDirect in E:\CBTechWeb\vision\dbconnect.php on line 10

    Warning: odbc_result_all(): supplied argument is not a valid ODBC result resource in E:\CBTechWeb\vision\dbconnect.php on line 13

    Any help on how to get this working would be great.

    Cheers.
    Mark

  • #2
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Check that the server has a system odbc connection for the database.
    Last edited by meth; 11-23-2006 at 04:31 AM.
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.

  • #3
    New Coder
    Join Date
    Sep 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yep its a system odbc pointing to v:\Vision\Home\Sample (im only using a sample database at the moment)

  • #4
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    SELECT * FROM customer

    case sensitive...
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.

  • #5
    New Coder
    Join Date
    Sep 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Does'nt make a difference

  • #6
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    This may be a stupid question, but are you sure there's a table in the db called customer?
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.

  • #7
    New Coder
    Join Date
    Sep 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is a screenshot

    http://www.thinkbigtechnology.com/vision.jpg

    I know it says "Customer' (uppercase C), but ive tried all different variations and it doesnt make a difference.

    I have tried several different tables too.

  • #8
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,072
    Thanks
    2
    Thanked 320 Times in 312 Posts
    It is apparently connecting to something but not where the customer.dbf file can be found, so this purely a guess, perhaps a trailing slash on the connection - v:\Vision\Home\Sample\
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #9
    New Coder
    Join Date
    Sep 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Tried that. No luck

  • #10
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    try echoing the out put of odbc_tables() to see what tables are in the db it's connecting to (not sure if this is correct for odbc functions ):
    PHP Code:
    <?php
    $connectionstring 
    odbc_connect("Vision.dsn""""");
    $tables odbc_tables$connectionstring );
    echo 
    "<table>\n";
    echo 
    " <tr>\n";
    echo 
    "  <td>Qual.</td>\n  <td>Name</td>\n<td>Type</td>\n <\tr>\n";
    do {
    echo 
    " <tr>\n";
    echo 
    '  <td>'.$tables['TABLE_QUALIFIER']."</td>\n";
    echo 
    '  <td>'.$tables['TABLE_NAME']."</td>\n";
    echo 
    '  <td>'.$tables['TABLE_TYPE']."</td>\n";
    echo 
    "  <\tr>\n";
    } while ( 
    $tables odbc_tables$connectionstring ) );
    echo 
    '</table>';
    At least that will tell you if you're barking up the wrong tree.
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.

  • #11
    New Coder
    Join Date
    Sep 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well,

    its something to do with network problems i think. All that script done was print out a heap of "<r>"s

    I decided to make a copy of the database, and put it locally on the webserver, and connect to that, and it worked fine. So there must be some permissions, However when on the server, i have the accounts server as a mapped network drive, i can access the files and everything fine. So im not sure, any ideas?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •