Jump to content

php my_sql connection problem


markpirvine

Recommended Posts

Hi,

 

I have a problem trying to connect to a my_sql database.  I'm very new to PHP, so this is probably a very simple problem.  At the top of my index.php I have the following code:

 

try

{

echo 'here 1';

$dbmysql_connect('localhost', 'root', 'password') or die(mysql_error());

echo 'here 2';

if(!$db)

{

echo 'here 3';

}

  $db_selected=mysql_select_db("alphaes", $db);

echo 'here 4';

 

if (!$db_selected) {

die ('Can\'t use foo : ' . mysql_error());

}

echo 'here 5';

}

catch (Exception $e)

{

echo 'Caught exception: ',  $e->getMessage(), "\n";

}

 

The problem is that the only output from the page is 'here 1'.  If I comment out all the database code the page loads ok.  There's something wrong with the connect code, however I don't see the mysql_error or exception.  Do these get logged to a file somewhere?  Can anyone see a problem with the code?

 

The username and password are correct.

 

Any help is much appreciated,

 

Mark

Link to comment
https://forums.phpfreaks.com/topic/223666-php-my_sql-connection-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.