A
A
Anton Schultz2020-02-09 13:47:00
SQL
Anton Schultz, 2020-02-09 13:47:00

Why is it giving an error when using WHERE in a query?

This query works

$sql = "SELECT `name`, `header`, `text` FROM `nature`"; 
 
if(result(->num_rows>0) 
while($res = $result->fetch_assoc()) 
echo $res['name'];


But when I try to make a selection with WHERE, it gives an error
$sql = "SELECT `name`, `header`, `text` FROM `nature` WHERE `id`=`1`";

if(result(->num_rows>0) 
while($res = $result->fetch_assoc()) 
echo $res['name'];


How to format the request correctly and not get the fetch_assoc error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lazy @BojackHorseman, 2020-02-09
@MrAnderson1999

`1` // столбец с названием 1
'1' // строка, содержащая один символ - единицу
1 // целое число, единица

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question