Jump to content

Parse error: syntax error, unexpected '$host_name' (T_VARIABLE) in /homepages/38/d597262079/htdocs/s/noosha/connect.php on line 2


newsha99

Recommended Posts

I wrote a connect.php to connect my databases with the registration and login forms 

It's saying it is finding an error in line 2 of my code which has the $host_name variable.

here's my code.

I dont know what im doing wrong

<? php

$host_name="db678077635.db.1and1.com";

$database="db678077635";

$username="dbo678077635"


I wrote a connect.php to connect my databases with the registration and login forms 

It's saying it is finding an error in line 2 of my code which has the $host_name variable.

here's my code.

I dont know what im doing wrong

<? php

$host_name="db678077635.db.1and1.com";

$database="db678077635";

$username="dbo678077635";

$password="[mypassword]";

 

$connect= mysqli_connect($host_name, $username, $password, $database);

 

if (mysqli_connect_errno()){

echo "<p> Failed to connect to MySQL:'.mysqli_connect_error()'.</p>";

}

else{

echo "<p> Connection to MySQL server successfully established.</p>";

}

?>


 

$connect= mysqli_connect($host_name, $username, $password, $database);

 

if (mysqli_connect_errno()){

echo "<p> Failed to connect to MySQL:'.mysqli_connect_error()'.</p>";

}

else{

echo "<p> Connection to MySQL server successfully established.</p>";

}

?>

Link to comment
Share on other sites

By doing that you are outputting internal errors to the user who has absolutely no use for that information. The one it is useful to is a hacker. You will need to learn proper error handling.

 

Since you are just starting out, now would be the time to start using PDO. You will find it easier to work with as well. Start with this tutorial https://phpdelusions.net/pdo

Link to comment
Share on other sites

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.