Skip to content

Wrong Charset #78

Description

@marcosfreitas

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:

charset

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);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions