Jump to content

how to connect php to mysql (any errors in code?)


duchaine1

Recommended Posts

Hi,

I need to ask if there are any errors in this code? Also, where should this be uploaded to in file mgr.?

(page name is connect.php)

<?php
$servername = "localhost";
$username = "itisok";
$password = "pwisok";

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

// Check connection
if (!$conn) {
  die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>

<html>
 <head>
 </head>
 <body>
 <h1>PHP connect to MySQL</h1>
</body>
</html>

Thanks,

LD

Link to comment
Share on other sites

7 minutes ago, duchaine1 said:

I need to ask if there are any errors in this code?

Yes - line 7.

Plus it's normal to specify a default database.

7 minutes ago, duchaine1 said:

where should this be uploaded to in file mgr.?

Depends what you want to do with it and what operating system you are using.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.