My Code:
if (isset($_POST['del'])) {
foreach ($_POST['del'] as $id){
if ($stmt = $mysqli->prepare("DELETE FROM `users` WHERE `̌id` = ?")) {
$stmt->bind_param('i', $id);
$stmt->execute();
} else {
printf("Errormessage: %s<br>", $mysqli->error);
}
}
}
Result: Errormessage: Unknown column '̌id' in 'where clause'
$_POST['del']
contains integers from checkboxes of a form.
However, this is used with the same connection earlier, and it works:
$modified = arrayRecursiveDiff($_POST, $data);
foreach($modified as $key => $val_arr) {
if (!is_array($val_arr)) {continue;}
foreach ($val_arr as $iteration => $val) {
$id = $iteration + 1;
$query = 'UPDATE users
SET '. $key .'="'. $val .'"
WHERE id = '. $id;
if (preg_match('/.*\sdel\=.*/',$query) === 0){
$mysqli->query($query);
}
}
}
Funniest thing is that I tried to echo that query and copy it directly into mysql command prompt. It worked perfectly...
I would appreciate if someone had an answer to what could possibly be going wrong here,
It seems like there's some weird character ( Edit: consult Footnotes ) that resembles a backtick just before id
, but in fact isn't.
I couldn't tell exactly from my editor, yet. ( Edit: consult Footnotes )
Change this line:
if ($stmt = $mysqli->prepare("DELETE FROM `users` WHERE `̌id` = ?")) {
to
if ($stmt = $mysqli->prepare("DELETE FROM `users` WHERE `id` = ?")) {
I just went into EDIT mode again (11:00 pm EDT) after you edited your question with the updated code and I copy/pasted your query line into my editor, and there is still a strange character between your first backtick and the word id
.
if ($stmt = $mysqli->prepare("DELETE FROM `users` WHERE `̌id` = ?")) {
^^
Copy/paste this actual code in your file. But I'm curious to know which file editor you're using that is causing this, or are you typing this by hand?
if (isset($_POST['del'])) {
foreach ($_POST['del'] as $id){
if ($stmt = $mysqli->prepare("DELETE FROM `users` WHERE `id` = ?")) {
$stmt->bind_param('i', $id);
$stmt->execute();
} else {
printf("Errormessage: %s<br>", $mysqli->error);
}
}
}
From what I found in my editor, it seemed to be ( either ) this unicode character ‎
that was before id
Unicode hex: 8206
Unicode decimal: 33286
UTF-8 Hex: e88886
HTML Entity: 舆
Source: http://www.htmlescape.net/82/character_8206.html
or this from: http://en.wikipedia.org/wiki/Left-to-right_mark
I quote: "The LRM causes the punctuation to be adjacent to only LTR text – the "C" and the LRM mark – and hence position as if it were in left-to-right text, ie, to the right of the preceding text. ‎
or ‎
may be required by some software rather than the invisible Unicode character itself; the actual invisible character would also make copy editing difficult. "
Added note: The Wikipedia information I found on the subject, I originally found while doing a Google search, which led me to this page which led me to The Wikipedia page I posted just above.
Another Unicode character that was in the original question was ̌
From unicodemap.org and I quote: "Unicode Character Map - 0x036F (aka "̌")"
Unicode Hexadecimal: 0x030C
Unicode Decimal: 780
UCS-2 Hexadecimal: 0x0C03
UCS-2 Decimal: 3075
HTML Hexadecimal: ̌
HTML Decimal: ̌
Character (which may be a bit hard to see):
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.