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
Go to solution Solved by benanamen,

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

  • Like 2
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.