Jump to content

Connecting to MySQL Database administered with MAMP Pro


MilesStandish

Recommended Posts

Hi,

 

Newbie here, I'm trying to retrieve data from a database that I set up using MAMP Pro.  Right now I'm just trying to verify that I'm even connecting to the DB at all.  I'm using the below code to do that:

 

<?php

require("dbinfo.php");

 

$connection=mysql_connect ($server, $username, $password);

if (!$connection) {

  echo "Could not connect to database!";

  else echo "Connected to database successfully!";

}

 

?>

 

The file "dbinfo.php" contains the database name, username, and password.  I know that that information is being passed to the script because I set up some echo statements and they showed the correct information is being passed.

 

However, the above code doesn't produce any output at all.  Shouldn't it echo one or the other statements in my browser?  Instead all I get is a completely blank page.

 

Sorry if this is obvious, as I stated, I am a newbie.

O.K., I found the error, I shouldn't have put in the curly braces.  However, now I know I am not connecting to the database.  I know the username, password, and db name are all correct.  Any suggestions as to what else to check?

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.