Unexpected boolean value in php mysql-Collection of common programming errors
Unexpected boolean value in php mysql
Carlos BergenI know for a fact that the content of inputbox that I’m submitting exists in table1, yet this query:
$check = mysqli_query($con, "SELECT name FROM table1 WHERE name=$_POST[inputbox]"); var_dump($check);
is giving me a bool(false)
What am I doing wrong?
-
3 Answers
Carlos BergenMaybe try:
$check = mysqli_query($con, "SELECT name FROM table1 WHERE name='".$_POST[inputbox]."'");
hek2mglA general advice, if you want to know whats going wrong, use
mysqli_error()
:$result = mysqli_query($con, '......'); if(!$result) { die(mysqli_error($con)); }
david_p6Check if the $con var is true because if the connection failed you will always get bool(false).
If it is ok try to update the query by name LIKE ‘” . $_POST[inputbox] . “‘;
Web site is in building
- tagged Related
- php
- mysql
- boolean
This site is an open site, the purpose is to guide more people to practice Test-Driven Development, details click here—more
I discovery a place to host code、demo、 blog and websites.
Site access is fast but not money