PDA

View Full Version : Mysql



Xena
January 22nd, 2002, 22:20
Is there a away to access a mysql database via php? My hosting company says to use this script

$hostname = "localhost";
$usernamedb = "username";
$passworddb = "your_password_here";
$dbName = "username";

MYSQL_CONNECT($hostname, $usernamedb, $passworddb);
@mysql_select_db("$dbName");


It didn't work! What did I do wrong?

niv
January 22nd, 2002, 22:26
Try removing the @ and replacing MYSQL_CONNECT with mysql_connect. I don't know if it is case sensitive or not.

Xena
January 22nd, 2002, 22:37
Didn't work :-(

harrylmh
January 23rd, 2002, 00:36
Maybe you got your database name wrong or something.
What I'd do is to see what the error is:

if (!mysql_connect($hostname, $usernamedb, $passworddb))
echo mysql_error();
if (!mysql_select_db("ur_dbname"))
echo mysql_error();

maybe the error message would be more informative like this.

ashben
January 23rd, 2002, 01:35
Shouldn't this ...

@mysql_select_db("$dbName");

.. be ..

mysql_select_db($dbName);

harrylmh
January 23rd, 2002, 02:32
oh yeah...