php - Query select x1 from table_n where x2 = 'Name' capital letter turns to small during search -
this question has answer here:
i try make query can retrieve x1 said in title (x1 in int) error appears:
my php code:
echo "the food is:"; echo $food; $query = "select foodid foods name = $food"; echo "the query is:"; echo $query; $result_id = pg_query($conn,$query) or die("query cannot executed"); the error:
warning: pg_query(): query failed: error: column "burito" not exist
i can not understand why somewhere between turns lower case.
in result of echos name burito shown correct (with capital b). hint helpful.
edit:
after fixed problem of wogsland noticed if echo $result_id outcome
resource id #8 but supposed number 149.
you're missing single quotes in sql query around $food:
$query = "select foodid foods name = '$food'"; that's why when $food = 'burito' you're running trouble. if there no single quotes assumes burito column name rather string.
Comments
Post a Comment