cancel
Showing results for 
Search instead for 
Did you mean: 

PAYH - Connect to database from php

thehat
Grafter
Posts: 39
Registered: ‎19-09-2007

PAYH - Connect to database from php

I have a plusnet (free-online) account and also a PAYH site.
I can connect to my PN database from my PN (ccgi) site and from my PAYH site.
I am trying to connect to my PAYH database from my PAYH site, but I keep getting an error.
Is there a different syntax required for connecting to the PAYH MySQL database?
I can't find any information at all on the PAYH site about this.
Here is what I am currently doing:
// free-online settings
$db_host  = "rumpus.force9.net";
// Pay as you host settings:
// $db_host  = "plesk-db01.plus.net";
$username = "XXXX";
$password = "XXXX";
$DB_name  = "XXXX";
    $chan = mysql_connect ($db_host, $username, $password);
mysql_select_db ($DB_name, $chan);

$sql = 'select ...
$result = mysql_query ($sql, $chan);
if ($myrow = mysql_fetch_array($result))
I can access the database fine using phpmyadmin through Plesk. I am using the same database name and password, and I can execute the same sql query with no problem.
The error I get from php is:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
Any suggestions appreciated.
TIA
Phil.
2 REPLIES 2
Pod
Grafter
Posts: 30
Registered: ‎26-04-2008

Re: PAYH - Connect to database from php

(Having written of my deep disappointment am withholding the text of my experiences for 24 hours, to allow time for reflection, before publishing the sorry saga)
culduthel
Dabbler
Posts: 14
Registered: ‎10-08-2007

Re: PAYH - Connect to database from php

Check the db connection in your php with:
$chan = mysql_connect ($db_host, $username, $password);
if (!$chan)
  echo "Unable to connect";
$sql = mysql_select_db(whatever, $chan);
if (!$sql)
  echo "Unable to select";
Might help narrow it down.