$conn=mysql_connect(`localhost'," root","") or die("Could not connect");
mysql_select_db("bng_nov",$conn) or die("could not connect database");

Open in new window

Parse error: syntax error, unexpected end of file, expecting '`' in C:\xampp\htdocs\display\db.php on line 4

I got the error
Scott Yong Asked:
Who is Participating?
Chris StanyonCommented:
Shaun has already pointed out the error, but on top of that you should NOT be using the myql* extension. It's deprecated in PHP 5.* and completely remove from PHP7. You need to switch to either mysqli or PDO:

$conn=mysqli_connect("localhost',"root","") or die("Could not connect");
mysqli_select_db("bng_nov",$conn) or die("could not connect database");

Open in new window

Shaun VermaakTechnical Specialist/DeveloperCommented:
Perhaps ` should be '
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Well, you changed the first \` to a \" which will generate the same error.

You must balance your quotes around localhost, so try "localhost" or 'localhost'. Whatever quote you use must be the same to start + end localhost.

Reread Shaun's comment carefully again. He suggested you change the leading \` to match the trailing \' around localhost.
Chris StanyonCommented:
Hey David.

Oops - that was a typo in my code, not the Authors ;)
Scott Yong Author Commented:
guys i settle it already i use
$servername = "localhost";
$username = "root";
$password = "";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
echo "Connected successfully";

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.