$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
Yong Scott Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun VermaakTechnical SpecialistCommented:
Perhaps ` should be '
Chris StanyonWebDevCommented:
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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 StanyonWebDevCommented:
Hey David.

Oops - that was a typo in my code, not the Authors ;)
Yong Scott 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

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.