E
E
Evgen Nova2015-10-22 22:21:01
PHP
Evgen Nova, 2015-10-22 22:21:01

An error in the php code, how to understand where?

There is an error somewhere in the code, I can not understand where?

if(!$db) {

    echo 'ERROR: Could not connect to the database.';
} else {

    if(isset($_POST['queryString'])) {
        $queryString = $_POST['queryString'];

        if(strlen($queryString) > 0) {

 
        $query = $db->query("SELECT name FROM MS_store WHERE name LIKE '$queryString%' LIMIT 10");
    
        if($query) {

            while ($result = $query->fetch_object()) {

            echo '</li><li onclick="fill(''.$result->value.'');
                        ">'.$result->value.'</li>';
            }
        } else {
            echo 'ERROR: There was a problem with the query.';
        }
    } else {

    }
} else {
    echo 'There should be no direct access to this script!';
}
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Litvinenko, 2015-10-22
@evgen_nova

not
a
syntax error, not escaped parentheses, and after the variable again as well in general

echo "</li><li onclick=\"fill( '{$result->value}');\">{$result->value}</li>";
even so

M
Michael, 2015-10-22
@scherbuk

look at the error report

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question