PDA

View Full Version : php mysql odbc across servers


flann
01-15-2007, 06:07 PM
I'm wondering how I would go about connecting a php application on my desktop to a database that is on a shared hosting server. The server is set up to allow my specific IP address to access the DB. I've installed the mysql odbc driver on my desktop. Here is the code for my connect with valueable info removed.


<?php
$db_host = "server.com";
$db_user = "username";
$db_pass = "password";
$db_name = "database";
$dsn = "DRIVER={MySQL ODBC 3.51 Driver};" .
"CommLinks=tcpip(Host=$db_host);" .
"DatabaseName=$db_name;" .
"uid=$db_user; pwd=$db_pass";

odbc_connect($dsn, $db_user, $db_pass);
?>


and here is the error i'm getting.

Warning: odbc_connect() [function.odbc-connect]: SQL error: [MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on 'localhost' (10061), SQL state S1T00 in SQLConnect in C:\projects\odbc\connect.php on line 11

scoutt
02-03-2007, 12:29 PM
if you are setup on localhost you cannot go outside to connect to the internet. You have to set it up so it is not localhost.