E
E
evgeny3252020-07-02 14:52:13
PHP
evgeny325, 2020-07-02 14:52:13

How to fix syntax error, unexpected ''$connection'' (T_CONSTANT_ENCAPSED_STRING), expecting ',?

Started learning how to work with a database. all the time it is not possible to make authorization
checked the connection and the error is syntax error, unexpected ''$connection'' (T_CONSTANT_ENCAPSED_STRING), expecting ',

<?php 
$connection = mysqli_connect('127.0.0.1', 'root', 'root', 'тут было название бд');

if( $connection == true){
  echo "нет";
    echo mysqli_error(  );
    die();
}

I've been sitting for half an hour, I think that with line 6, or rather with this echo mysqli_error ( );

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nokimaro, 2020-07-02
@nokimaro

https://www.php.net/mysqli_error
mysqli_error ( mysqli $link ) : string
you need to pass a connection descriptor to mysqli_error(), in your case $connection.
echo mysqli_error($connection);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question