0

Hi guys I am new on PHP and have this problem:

( ! ) Parse error: syntax error, unexpected 'yes' (T_STRING) in C:\wamp64\www\init.php on line 13

This is my code:

<?php   

$host = "localhost";
$db_user = "****";
$db_password = "****";
$db_name = "user_db;

mysqli_connect($host,$db_user,$db_password,$db_name);

if($con)
{

    echo "Connection Success";

}

else
{

    echo "Connection failed";

}

?>

This tutorial I am trying to follow:

https://www.youtube.com/watch?v=dxVPGnP_PFM

Can anyone help me please?

SiHa
  • 7,830
  • 13
  • 34
  • 43
Behar
  • 239
  • 1
  • 6
  • 15
  • 1
    You did not close the quotes at line 6 . But there is no "yes" in this file, so I suspect that the error is in a different file. Also, you do not define $con - it is probably `$con = mysqli_connect(...`. – LSerni Feb 28 '17 at 10:33
  • Possible duplicate of [PHP Parse/Syntax Errors; and How to solve them?](http://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – Funk Forty Niner Mar 05 '17 at 23:48

1 Answers1

0

$con is missing on line no 8. Where else you are checking it on line no 10 but can not do that until you declare it before the if-statement. Replace line no 8 to this.

$db_name = "user_db";
//                 ^   missing closing quote

$con = mysqli_connect($host,$db_user,$db_password,$db_name);
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
thakur.B
  • 86
  • 7
  • 2
    Still, as stated by @LSerni the closing quotes on line 6 are missing. – fragmentedreality Feb 28 '17 at 10:43
  • If this answered your question you might consider accepting it. For more information please see http://stackoverflow.com/help/someone-answers and the rest of the help. It is probably a good idea to take the [tour](http://stackoverflow.com/tour). – fragmentedreality Mar 07 '17 at 06:36