Jump to content

HELP! Can't get database connection to work.


KickStarter

Recommended Posts

Hello everybody.  :pirate:

 

I am trying to connect my website to the database. However, I keep getting an error in my php code to connect to the database.

Heres the code:

 

<?php
$sqlhostname = "localhost";
$sqlusername = "root";
$sqlpassword = "";
$sqldatabase = "login"

$conn = mysql_connect($sqlhostname, $sqlusername, $sqlpassword) or die(mysql_error());

if($conn){
mysql_select_db($sqldatabase); 
}else{
print("can't connect to database");
}
?>

 

When I test my php file using wampserver, I get the following error: " Parse error: syntax error, unexpected '$conn' (T_VARIABLE) in C:\wamp\www\web\mysql.php on line 7"

 

What am I missing? It looks right from my perspective. Also, I am quite new to PHP.

 

Thanks ;D

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.