We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm using charset latin1 on my database and my pages have iso-8859-1 codification and I'm including this code on all pages to force it:
header('Content-type: text/html; charset=ISO-8859-1');
But when I try to insert string with special characters the query fails with this report:
This is my query:
// the parameters for the query bellow $params = array ( //"fk_user" => $this->fk_user, "fk_user" => 1, "ad_title" => $this->ad_title, "ad_description" => $this->ad_description, "ad_files" => "image1.jpg,image2.jpg,image3.jpg", "ad_type" => (int) $this->ad_type, "ad_mode" => (int) $this->ad_mode, "ad_reward" => (float) $this->ad_reward, "ad_location" => $this->ad_location, //dates inside the query.., "ad_status" => $this->ad_status, "ad_slug" => $this->ad_slug, "ad_tags" => $this->ad_tags, ); // the query $sql = 'REPLACE INTO ads ('; $sql .= 'fk_user, ad_title, ad_description, ad_files, ad_type, ad_mode, ad_reward, ad_location, ad_cdate, ad_udate, ad_status, ad_slug, ad_tags, ad_solved, ad_reports'; $sql .= ') VALUES ('; $sql .= ':fk_user, :ad_title, :ad_description, :ad_files, :ad_type, :ad_mode, :ad_reward, :ad_location, NOW(), NULL, :ad_status, :ad_slug, :ad_tags, 1, 0'; $sql .= ')'; // execute the query $add = $db->query($sql, $params);
The text was updated successfully, but these errors were encountered:
I can fix using utf8_encode() on all strings that have special characters inside $params array. But why? lol
utf8_encode()
$params
"ad_title" => utf8_encode($this->ad_title)
See bellow that those two last lines have correct charset. They has been inserted with REPLACE INTO (see https://github.com/indieteq/indieteq-php-my-sql-pdo-database-class/issues/77) and using utf8_encode()
REPLACE INTO
Sorry, something went wrong.
No branches or pull requests
I'm using charset latin1 on my database and my pages have iso-8859-1 codification and I'm including this code on all pages to force it:
header('Content-type: text/html; charset=ISO-8859-1');
But when I try to insert string with special characters the query fails with this report:
This is my query:
The text was updated successfully, but these errors were encountered: