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 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    odbc connect script for mysql

    i have a php odbc connect script for a ms access database as shown below

    <?
    $odbc = odbc_connect ('DIT_test.mdb', '', '') or die( "Could Not Connect to ODBC Database!");
    if (function_exists(odbc_fetch_array))
    return;
    function odbc_fetch_array($result, $rownumber=-1)
    {
    if (PHP_VERSION > "4.1")
    {
    if ($rownumber < 0)
    {
    odbc_fetch_into($result, $rs);
    }
    else
    {
    odbc_fetch_into($result, $rs, $rownumber);
    }
    }
    else
    {
    odbc_fetch_into($result, $rownumber, $rs);
    }

    $rs_assoc = Array();
    foreach ($rs as $key => $value)
    {
    $rs_assoc[odbc_field_name($result, $key+1)] = $value;
    }
    return $rs_assoc;
    }
    ?>

    would this have to be changed to run a mysql database instread of the access one? i've tried using this for a mysql database with no luck, what would i need to change (apart from the database name!) if anything?
    cheers
    steve

  • #2
    Regular Coder
    Join Date
    Jun 2005
    Posts
    804
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP has a separate set of functions for different database types. The logic should be more or less the same, but you need to replace all your odbc functions with MySQL functions. The 'important' ones are mysql_connect(), mysql_select_db(), mysql_query(), and the various mysql_fetch_ functions.

  • #3
    Regular Coder devinemke's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    443
    Thanks
    0
    Thanked 12 Times in 11 Posts

  • #4
    New Coder
    Join Date
    Apr 2005
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thqanks for those replies, problem solved
    steve


  •  

    Posting Permissions

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