FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


HomeWatched TopicsRegisterSearchDirectory
FAQMemberlistUsergroupsLog inStoresItemsBank
Google

Reply to topic Page 1 of 1
php to mysql -> utf-8 problem
Message  

Reply with quote
Post php to mysql -> utf-8 problem 
i had create a form called registerForm.php and had set the charset to utf8

In the form, there are some textfield which the user will input some chinese characters and when submit, it will post to register.php and write the entry into the database.  It works well when i am testing it on the windows machine.

But with the testing being done on the hosting server which is Linux SuSe, the chinese character that writes to the database is not utf8 coding anymore instead it show some funny character.  Y is that so?  Btw i am using apache 2 server, mysql server 4.1 and php5.

View user's profile Send private message

Reply with quote
Post  
If i may suggest changing the actual page where the registration takes place to register.php and when the form data is submitted it takes them to handel_form.php.

To assist you in your problems, please post your code here.

View user's profile Send private message

Reply with quote
Post  
registerForm.php coding as follow

<?
$host='localhost';
$username='root';
$password='asd';
$connection = mysql_connect($host,$username,$password);
mysql_select_db("data");
$qualificationList = mysql_query ("SELECT * FROM admin_qualification");
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <form action="register.php" method="post" name="register_form" target="_parent" id="register_form">
      <table width="100%"  border="1" cellspacing="0" cellpadding="0">
        <tr bgcolor="E5CF73">
          <td colspan="2"><span class="style31">Personnal Information </span></td>
        </tr>
        <tr>
          <td width="33%" bgcolor="#FFFFFF"><span class="style39">Chinese Name * </span></td>
          <td width="67%"><input name="text_chinesename" type="text" id="text_chinesename"></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF"><span class="style39">Surname * </span></td>
          <td><input name="text_firstname" type="text" id="text_firstname"></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF"><span class="style39">Last Name * </span></td>
          <td><input name="text_lastname" type="text" id="text_lastname"></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF"><p class="style39">Qualification * </p>            </td>
          <td><select name="list_qualification" id="list_qualification">
        <?  
          $counter = 0;
               while ($row = mysql_fetch_array($qualificationList)) {
         ?>
              <option value="<? echo $row["qualification"]; ?>"> <? echo $row["qualification"]; } ?>

          </select> <span class="style49">
      </table>
      <p align="center">
        <input name="Submit" type="submit" value="Submit" >
        &nbsp;&nbsp;
        <input name="Reset" type="reset" id="Reset" value="Reset">
</p>
      </form>


register.php coding as follow

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
$host = "localhost"; // hostname...in our case localhost
$username = "root"; // root is our default
$password = "asd"; // your mysql password please
$connection = mysql_connect("$host","$username","$password");

$select_success = mysql_select_db("data");

$chinesename = $_POST['text_chinesename'];
$firstname=$_POST['text_firstname'];
$lastname=$_POST['text_lastname'];
$Qualification=$_POST['list_qualification'];

if(empty($chinesename))
{
       echo"Please make sure all the required field are being entered or chosen. //chinese name \n";
    echo "Please back click to continue.";
    //echo "</p>";
      //echo "<a href='/register.html' onclick='self.history.back();'>Back</a>";
        exit;
}

if(empty($firstname))
{
        echo"Please make sure all the required field are being entered or chosen. //first name \n";
      echo "Please back click to continue.";
    //echo "</p>";
      //echo "<a href='/register.html' onclick='self.history.back();'>Back</a>";
        exit;
}

if(empty($lastname))
{
 echo"Please make sure all the required field are being entered or chosen. //last name \n";
       echo "Please back click to continue.";
    //echo "</p>";
      //echo "<a href='/register.html' onclick='self.history.back();'>Back</a>";
        exit;
}

if(empty($Qualification))
{
    echo"Please make sure all the required field are being entered or chosen. //qualification \n";
   echo "Please back click to continue.";
    exit;
}

else
{
mysql_query ("INSERT INTO user (chineseName, firstName, lastName,qualification) VALUES ('$chinesename', '$firstname', '$lastname', '$Qualification')");
echo "You have successfully register";
}
mysql_close();
?>

View user's profile Send private message
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  



Google

FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


Web Design by PlatinumShore.com & Web Hosting by TradeWebHosting.com