2
votes

I am getting this error from the following code:

$result = odbc_connect("DRIVER={MySQL ODBC 3.51 Driver};Server=localhost;Database=$database_name",$database_username, $database_password);

Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /dbconnect.php on line xx odbc not connected

I am using MySQL version 5.1.41-3ubuntu12.3

My phpinfo gives the following output:

Additional .ini files parsed /etc/php5/apache2/conf.d/odbc.ini, /etc/php5/apache2/conf.d/pdo_odbc.ini  

odbc
----

ODBC Support            enabled <br>
1
Why are you using ODBC to connect to MySQL? Why not use either PDO or MySQLi? - ircmaxell
This is an already existing source, so I have to use this. - Ozair Kafray

1 Answers

3
votes

You must have an ODBC driver installed. http://packages.ubuntu.com/hardy/unixodbc