I created a module to keep my database code separate from my HTML code, and I used the following function to connect to the database...
function Do_Connect() {
$db = mysql_connect($server, $username, $password);
mysql_select_db('database', $db);
return $db;
};
Then in the webpage, I include the module and call the function like so:
$db = Do_Connect();
$result=mysql_query("select * from table", $db);
This works perfectly on my intranet at home, running PHP and IIS on an NT 4.0 server (yeah, yeah... I know).
However, when I try it on my webhost's server, which is a Unix flavor (can't remember which) running PHP 4, it doesn't work and gives me an error. I have to actually write the connect and select_db code in the webpage rather than calling the function.
Any ideas why?
function Do_Connect() {
$db = mysql_connect($server, $username, $password);
mysql_select_db('database', $db);
return $db;
};
Then in the webpage, I include the module and call the function like so:
$db = Do_Connect();
$result=mysql_query("select * from table", $db);
This works perfectly on my intranet at home, running PHP and IIS on an NT 4.0 server (yeah, yeah... I know).
However, when I try it on my webhost's server, which is a Unix flavor (can't remember which) running PHP 4, it doesn't work and gives me an error. I have to actually write the connect and select_db code in the webpage rather than calling the function.
Any ideas why?