Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. arabic text is saved as unreadable characters

arabic text is saved as unreadable characters

Scheduled Pinned Locked Moved Database
helpphpdatabasemysqlcom
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    Hi, I am having a problem saving from my php for to MySQL database. I am not sure if the problem is at the PHP level or database level. here is the form: http://www.jassimrahma.com/contactme[^] and when submiting arabic characters... it will be saved as unreadable characters like this: http://www.jassimrahma.com/arabic.png[^] My database character set is UTF-8 Unicode and Collation is utf8_general_ci here is my table DDL:

    CREATE TABLE `mubadara_messages` (
    `message_id` int(11) NOT NULL AUTO_INCREMENT,
    `message_from_name` varchar(255) DEFAULT NULL,
    `message_from_email` varchar(255) DEFAULT NULL,
    `message_subject` varchar(255) DEFAULT NULL,
    `message_body` text,
    `message_ip_address` varchar(255) DEFAULT NULL,
    `created_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`message_id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

    and this is my PHP:

    require 'PHPMailer/class.phpmailer.php';

    $message_visitor_name = $_POST['txtName'];
    $message_visitor_email = $_POST['txtEmail'];
    $message_subject = $_POST['txtSubject'];
    $message_body = $_POST['txtMessage'];
    $message_ip_address = $_SERVER['REMOTE_ADDR'];

    // save the message
    $mysql_connection = mysql_connect('mysql.jassimrahma.com', 'jassimdb', 'Mujtaba2013');
    mysql_select_db('jassimrahma_com', $mysql_connection);

    // $mysql_connection = mysql_connect('localhost', 'root', 'xxxxxxxxxxxx');
    // mysql_select_db('jassimrahma', $mysql_connection);

    $mysql_command = "INSERT INTO mubadara_messages (message_from_name, message_from_email, message_subject, message_body, message_ip_address) VALUES ('$message_visitor_name', '$message_visitor_email', '$message_subject', '$message_body', '$message_ip_address')";
    $mysql_result = mysql_query($mysql_command, $mysql_connection) or die(mysql_error());
    // $mysql_result = mysql_query("SELECT project_name FROM projects WHERE project_id = 13");
    // echo $mysql_result;
    mysql_close($mysql_connection);

    exit(header("Location: thankyou"));

    can anyone help please Thanks, Jassim

    Technology News @ www.JassimRahma.com

    B 1 Reply Last reply
    0
    • J Jassim Rahma

      Hi, I am having a problem saving from my php for to MySQL database. I am not sure if the problem is at the PHP level or database level. here is the form: http://www.jassimrahma.com/contactme[^] and when submiting arabic characters... it will be saved as unreadable characters like this: http://www.jassimrahma.com/arabic.png[^] My database character set is UTF-8 Unicode and Collation is utf8_general_ci here is my table DDL:

      CREATE TABLE `mubadara_messages` (
      `message_id` int(11) NOT NULL AUTO_INCREMENT,
      `message_from_name` varchar(255) DEFAULT NULL,
      `message_from_email` varchar(255) DEFAULT NULL,
      `message_subject` varchar(255) DEFAULT NULL,
      `message_body` text,
      `message_ip_address` varchar(255) DEFAULT NULL,
      `created_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
      PRIMARY KEY (`message_id`)
      ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

      and this is my PHP:

      require 'PHPMailer/class.phpmailer.php';

      $message_visitor_name = $_POST['txtName'];
      $message_visitor_email = $_POST['txtEmail'];
      $message_subject = $_POST['txtSubject'];
      $message_body = $_POST['txtMessage'];
      $message_ip_address = $_SERVER['REMOTE_ADDR'];

      // save the message
      $mysql_connection = mysql_connect('mysql.jassimrahma.com', 'jassimdb', 'Mujtaba2013');
      mysql_select_db('jassimrahma_com', $mysql_connection);

      // $mysql_connection = mysql_connect('localhost', 'root', 'xxxxxxxxxxxx');
      // mysql_select_db('jassimrahma', $mysql_connection);

      $mysql_command = "INSERT INTO mubadara_messages (message_from_name, message_from_email, message_subject, message_body, message_ip_address) VALUES ('$message_visitor_name', '$message_visitor_email', '$message_subject', '$message_body', '$message_ip_address')";
      $mysql_result = mysql_query($mysql_command, $mysql_connection) or die(mysql_error());
      // $mysql_result = mysql_query("SELECT project_name FROM projects WHERE project_id = 13");
      // echo $mysql_result;
      mysql_close($mysql_connection);

      exit(header("Location: thankyou"));

      can anyone help please Thanks, Jassim

      Technology News @ www.JassimRahma.com

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      Not sure. You might need to add a

      mysql_set_charset('utf8');

      between the connection and the selection of the db.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups