[FX.php List] Connecting PHP Web Pages with ODBC

John Funk csinfo at criticalsolution.com
Thu Apr 25 12:46:45 MDT 2013


Try this for starters, I use this for reference.

<?php
$conn=odbc_connect('dbname','username','pass'); //set the parameters for
the connection
if (!$conn)
  {exit("Connection Failed: " . $conn);} //exit if the connection fails

  
$sql="<sql statement here>"; //set the sql statement

$rs=odbc_exec($conn,$sql); //call the connection with the statement
if (!$rs)
  {exit("Error in SQL");} //exit if thesql is bad

// get the field data from the result
while (odbc_fetch_row($rs))
{
        $field_one=odbc_result($rs,"<field_one>");
        $field_two=odbc_result($rs,"<field_two>");

echo $field_one."   ". $field_two ."\n"; // show the data on your web page
}

odbc_close($conn);
?>



>
>
>Hi John Glyn & Dale,
>
>Thanks for all the helpful tips.
>
>The thing I am still in the dark about is how to write the php to access
>the filemaker database with ODBC?
>
>So, as a test I have succesfully created an odbc connection to a
>(localhost) filemaker database (I also will use fmserver soon).
>
>Now I would like to know a way - using PHP to setup a connection to the
>filemaker database and perform queries from a local webpage.
>
>Here's some connection info...
>
>ip = xxx.xxx.xxx.??? - any special port
>USER DSN = test1
>database = MyDB
>
>I just don't know how to write the ODBC connection code in PHP?
>
>Any ideas?
>
>
>
>--
>Thanks,
>Dave - DealTek
>dealtek at gmail.com
>[db-3]
>
>_______________________________________________
>FX.php_List mailing list
>FX.php_List at mail.iviking.org
>http://www.iviking.org/mailman/listinfo/fx.php_list




More information about the FX.php_List mailing list