0

I am playing around with PHPFog and as a result I ended up with a MySql database. I am trying to figure out how to connect to it with a success message.

PHPFog says use this:

mysql_connect(
  $server = getenv('MYSQL_DB_HOST'),
  $username = getenv('MYSQL_USERNAME'),
  $password = getenv('MYSQL_PASSWORD'));
mysql_select_db(getenv('MYSQL_DB_NAME'));

So I basically plug my variables into the above? Or Do I do something different?

Thanks, Jim

jim dif
  • 641
  • 1
  • 8
  • 17

1 Answers1

1

Yes, you can simply plug your host, user, password, and database name into this. There's nothing magic about using getenv to retrieve those values.

But, please be aware that mysql_connect() and related functions in that PHP api have been cracked. You should switch to using MySQLi http://php.net/manual/en/book.mysqli.php or PDO http://php.net/manual/en/book.pdo.php.

O. Jones
  • 103,626
  • 17
  • 118
  • 172
  • Thanks Ollie, The first time around I tried similar I got an error. Also thanks for the heads up on MySQLi. ~Jim – jim dif Sep 06 '12 at 16:21