0
<?php

$dbhost = '127.0.0.1';

$dbuser = 'root';

$dbpass =  'pass';

$conn = mysql_connect($dbhost, $dbuser, $dbpass;)

print $conn;

so here's my little snippet of code, I'm currently following along to a youtube video to create a clone website. this is what is written so far. then I exit out of vim the php index.php and I get this error. when watching the video this error isn't received by him even though its the same exact code as the video

PHP Parse error:  syntax error, unexpected '$conn' (T_VARIABLE) in /var/www/html/index.php on line 5

my knowledge of php is very low so any help would be appreciated

BEingprabhU
  • 1,618
  • 2
  • 21
  • 28
esal
  • 1
  • 2
  • $conn = mysql_connect($dbhost, $dbuser, $dbpass;) here you did put the `;` inside the function parameter – Rkv88 - Kanyan Feb 28 '20 at 22:33
  • Firstly MySQL is deprecated. You should be using Mysqli. Secondly, the semicolon(`;`) is inside the mysql_connect method. It should be outside. – BEingprabhU Feb 28 '20 at 22:33
  • Please refer https://www.w3schools.com/php/php_mysql_connect.asp to understand the basics on how you connect to the database – BEingprabhU Feb 28 '20 at 22:37
  • root@ip-172-31-40-7 html]# php index.php PHP Parse error: syntax error, unexpected '$dbuser' (T_VARIABLE) in /var/www/html/index.php on line 5 – esal Feb 28 '20 at 22:38
  • @beingprabhu i used both of your suggestions and i ended up with a different error. The link you provided looks like it had a lot of useful information thank you! – esal Feb 28 '20 at 22:40
  • There's no semicolon after `$dbhost = '127.0.0.1'`, and the next two lines are commented out, so the `$conn` is unexpected because the previous instruction was not terminated. – Don't Panic Feb 28 '20 at 22:43
  • Okay, those lines _were_ commented in the original post. Now `$dbuser` is unexpected for the same reason. – Don't Panic Feb 28 '20 at 22:45

0 Answers0