Nrc Nrc - 2 months ago 7
MySQL Question

Find text with like

I want to find text in a MySql database

$result = mysqli_query($con,"SELECT * FROM blog
WHERE text_post LIKE = 't%';
")
or die(mysqli_error());
while($row = mysqli_fetch_array($result)) {
echo $row['titol_post'] . "<br>";
}


It gives me the error:
mysqli_error() expects exactly 1 parameter, 0 given...

If I substitute

WHERE text_post LIKE = 't%';


by

WHERE text_post = 'test';


It works well. I do not undestand. Why the LIKE does not work?

Answer

I just changed like = to like and it works

SELECT * FROM blog WHERE text_post LIKE 't%'"

Comments