daint
asked on
ODBC Connector to MySQL DB
Hello,
I'm currently trying to connect to a database through a PHP script using the ODBC Connector. My lines of code are as follows:
$dsn = "DRIVER={MySQL ODBC 3.51 Driver};" .
"CommLinks=tcpip(Host=loca lhost);" .
"DatabaseName=handheld;" .
"uid=handheld; pwd=handheld";
$conn = odbc_connect($dsn, "handheld", "handheld");
// Insert statement
$stmt = odbc_prepare($conn, "TRUNCATE TABLE tbl_routing;");
// Check for errors in SQL statement
if (!odbc_execute($stmt))
{
echo "There has been an error!! - CONNECT";
}
However, I keep getting the error:
Warning: odbc_execute(): SQL error: [unixODBC][MySQL][ODBC 3.51 Driver][mysqld-4.1.12]No database selected, SQL state 3D000 in SQLExecute
I am trying this on a CentOS 4.3 install, php 4.3 and the ODBC 3.51 - MySQL connector installed.
Any more information available on request. By the way, I need an ODBC connection to the DB as MySQL is only being used temporarily, it will eventually run on a seperate ODBC DB.
Thanks
I'm currently trying to connect to a database through a PHP script using the ODBC Connector. My lines of code are as follows:
$dsn = "DRIVER={MySQL ODBC 3.51 Driver};" .
"CommLinks=tcpip(Host=loca
"DatabaseName=handheld;" .
"uid=handheld; pwd=handheld";
$conn = odbc_connect($dsn, "handheld", "handheld");
// Insert statement
$stmt = odbc_prepare($conn, "TRUNCATE TABLE tbl_routing;");
// Check for errors in SQL statement
if (!odbc_execute($stmt))
{
echo "There has been an error!! - CONNECT";
}
However, I keep getting the error:
Warning: odbc_execute(): SQL error: [unixODBC][MySQL][ODBC 3.51 Driver][mysqld-4.1.12]No database selected, SQL state 3D000 in SQLExecute
I am trying this on a CentOS 4.3 install, php 4.3 and the ODBC 3.51 - MySQL connector installed.
Any more information available on request. By the way, I need an ODBC connection to the DB as MySQL is only being used temporarily, it will eventually run on a seperate ODBC DB.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think this
"DatabaseName=handheld;" .
should be changed to
"DatabaseName=handheld" .
In any case there is something wrong with your clause, "DatabaseName=handheld;" ., so no databse is specified