php mysql connect
Posted by: STHayden
Posted on: 2005-04-22 19:47:00
using this code
<code>
//set the conections
define('DB_USER', 'sthayden');
define('DB_PASSWORD', 'PASSWORD');
define('DB_HOST', 'metrocss.stefanhayden.com');
define('DB_NAME', 'metrocss');
//make the connection then select the database
$dbc = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$dbc) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db(DB_NAME);
</code>
I get this error: Could not connect: Lost connection to MySQL server during query
if I take out the mysql_error() I get this error message: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
because of " PHP's allow_url_fopen NOW Disabled (Action Required)" I've had to move my project for graduation. I'd use the CURL sugested but don't completly understand it can't seem to get it to work from other's examples.
any help would be amazing
Stefan