I have set up an ODBC driver to a MySQL DB. Excel can connect and retreive data from the DB via this ODBC DSN. However when I write a php script to access the DSN I get:
Warning: odbc_connect() [function.odbc-connect]: SQL error: , SQL state 00000 in SQLConnect in C:Program FilesApache Software FoundationApache2.2htdocsODBCtestingODBCconnect.php on line 9
Line 9 is the call to the password. Excel does not use us username or password to connect to the ODBC, the ODBC has the user & pass for the MySL DB.
[code]$DSN=‘WebTrends Testing DSN’;
$DSNuser=‘connerys’;
$DSNpass=‘29080’;
$conn=odbc_connect(“WebTrendsDSNtest2”,"","");
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql=“SELECT Browsers_0.Browser, Browsers_0.Visits, Browsers_0.TimePeriod, Browsers_0.StartDate, Browsers_0.EndDate
FROM Browsers Browsers_0
WHERE (Browsers_0.TimePeriod=‘2008.m03’)
ORDER BY Browsers_0.Visits DESC, Browsers_0.Browser DESC”;
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit(“Error in SQL”);}
echo “
Browsers_0.Browser | ”;Browsers_0.Visits |
---|---|
$Browsers_0.Browser | ”;$Browsers_0.Visits |
Thanks in advance for your help.