0

I have this problem with my code it says: Parse error: syntax error, unexpected '$db_name' (T_VARIABLE) in line 4

 <?php

 $db_host = 'localhost'
 $db_name = 'quizzer'
 $db_user = 'root'
 $db_pass = '121212aa'

 $mysqli = new mysqli ($db_host, $db_pass, $db_name);

 if($mysqli->connect_error) {
    printf("Nem sikerult csatlakozni: %s\n", $mysqli->connect_error) }

 ?>
  • A proper IDE with syntax highlighting would save you a lot of trouble. Highlighting shows immediately all syntax errors and where they happen. – Dharman May 01 '19 at 22:11

2 Answers2

2

You are getting this because you don't have semicolons in your code. PHP requires each line be terminated with a semicolon.

<?php

$db_host = 'localhost';
$db_name = 'quizzer';
$db_user = 'root';
$db_pass = '121212aa';

$mysqli = new mysqli ($db_host, $db_pass, $db_name);

if($mysqli->connect_error) {
    printf("Nem sikerult csatlakozni: %s\n", $mysqli->connect_error); }

?>
  • Thank you so much, i expected but i thought its not a big problem – Nandor's Games May 01 '19 at 21:34
  • @Nandor'sGames Programming is a very exact art. There are some languages that can try to figure out where to insert semicolons, but it is always better to just add them in to be sure. – Tyler Carter May 01 '19 at 21:41
0

You missed many ';' when declare parameters,also mysql should take 4 parameters IP,username,password,database name,but you have only 3 of them inserted in constructor.

Berianidze Luka
  • 181
  • 3
  • 10