I have numbers/digits and characters too in string. I want to insert it into database using mysqli bind_param('s', $string)
. Is it okay or I have to use si both or what?
It is okay.
If you bind the parameter as int:
$stmt->bind_param('i', $bar);
Then the query will be about equivalent to:
INSERT INTO foo VALUES (42)
However, if you bind as string:
$stmt->bind_param('s', $bar);
The query will be about equivalent to:
INSERT INTO foo VALUES ('42')
A sequence of characters that contains both letters and digits is a string. You should use s
for it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.