开发者

MYSQLI::prepare() , error when used placeholder :something

开发者 https://www.devze.com 2023-02-15 18:53 出处:网络
hi im using mysqli and i saw some examples using placeholder like :something and ? when i used ? its working, but when i used :something in query like this

hi im using mysqli and i saw some examples using placeholder like :something and ?

when i used ? its working, but when i used :something in query like this

$sql = INSERT INTO food(food_name) VALUES(:food_name)

then error showed up when i called

$mysqli_object->prepare(开发者_如何学C$sql);

error message sounds like this

User Error! You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':food_name)' at line

but when i used ? as the placeholder, everything working well, i used PHP 5.3.1 and MySQL 5.1.41

am i missed somewhere, any help will be appreciated thanks


mysqli does not support named placeholders.

PDO does, using either bindParam or execute.

(Careful, you can only use a named placeholder once per query. They aren't too incredibly useful.)

0

精彩评论

暂无评论...
验证码 换一张
取 消