[FX.php List] Connecting PHP Web Pages with ODBC
dealTek
dealtek at gmail.com
Thu Apr 25 13:32:32 MDT 2013
Hi John and all,
Thanks for all the help....
using 1.8.3 mac
now FM Pro advanced 11 with updated odbc from FM - file is open and ODBC is on for this user (I will move to fmserver soon)
ODBC Manager will not store SYSTEM DSN - hmmm maybe permissions issue? how do I fix this?
Glyn mentioned to use System level DSN so I'll try that when I fix permissions?
so I'm using USER DSN - which does pass tests
odbc datasource name = myuserdsn
fm database = test1
table = mytable
(with 2 fields = first and last)
the error says:
Warning: odbc_connect() [function.odbc-connect]: SQL error: [iODBC][Driver Manager]Data source name not found and no default driver specified. Driver could not be loaded, SQL state IM002 in SQLConnect in /Users/revdave/Sites/multisite-general/odbc1/z1.php on line 34
Connection Failed:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$dbname = 'test1';
$username = 'web';
$pass = 'web';
$conn=odbc_connect('$dbname','$username','$pass'); //set the parameters for the connection
if (!$conn)
{exit("Connection Failed: " . $conn);} //exit if the connection fails
$sql="select * from mytable"; //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,"first");
$field_two=odbc_result($rs,"last");
echo $field_one." ". $field_two ."\n"; // show the data on your web page
}
odbc_close($conn);
?>
On Apr 25, 2013, at 11:46 AM, John Funk <csinfo at criticalsolution.com> wrote:
> 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
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
--
Thanks,
Dave - DealTek
dealtek at gmail.com
[db-3]
More information about the FX.php_List
mailing list