Switching for ANSI to UTF-8 and Query syntex

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

DvirDude
New php-forum User
New php-forum User
Posts: 1
Joined: Wed Nov 13, 2013 11:51 am

Switching for ANSI to UTF-8 and Query syntex

Postby DvirDude » Wed Nov 13, 2013 12:54 pm

Hi.
I am a novice php programmer and I am writing a web app in php for managing a database.
I am using XAMPP to run Apatch and MySQL.

Fisrt question:
I wrote a large part of the code and when I inserted code which had accented letters and saved it they would later display as "?".
After consulting a friend I've switched the encoding from ANSI to UTF-8 and now the accented letters are saved correctly but when I display them on the web page they would still show as "?".
How can I make them display correctly and could there be any problems caused by the transfer to UTF-8?

Second question:
The following code is a script which recives a product Id and reads it from the products table. Then it inserts it to the current order that the user is working on.

Code: Select all

<head>
<script type="text/javascript" src="MathJax/MathJax.js?config=TeX-AMS-

MML_HTMLorMML">
</script>
</head>

<?php
session_start();
if (isset($_SESSION['loggedin']))
{
   if ($_SESSION['loggedin'] == true)
   {
      
      if($_SESSION['Type'] == 'IsAdmin')
      {

         require("admin/global.php");

         $product_id=$_GET['Id'];

         $Order_Number=$_SESSION['curr_order'];
         
         $sql="SELECT * FROM `produits` WHERE Id =".$product_id."";
         $result=$funk->ins_vals($sql);

         $rows=mysql_fetch_array($result);

         $sql="INSERT INTO `order".$Order_Number."`(`FAB`, `Reference`, `Produit`, `Qte`, `Colis`, `Stock`, `place`, `Livre`, `Commentaires`) VALUES ('FAB',$rows['Code'],'$rows['Libellé']','0','0','0','0','0','0')";
         $result=$funk->ins_vals($sql);
         if($result)
         {
            header("location:Employee_Handle.php?Id=".$Order_Number);
         }
         else
         {
            echo "Error creating an order";
            echo "<a href=Employee_Handle.php?Id=<?php echo $Order_Number?>>Try again</a><br>";
            echo "<a href=Manage_Orders.php>Return to

manage orders</a>";
         }
         mysql_close();
      }
      else
      {
         

      }
   }
   else
   {
      header("location:main_login.php");
   }
}
else
{
header("location:main_login.php");
}
?>


I keep getting:
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\MADAProject\add_product.php on line 27

When I replace the query with one which does not condtains the first query output, it works fine but then, for some reason, it won't pass along the $order_number var.

Thanks in advance! If you read it all and are willing to help, then you must have a strong heart! :)

Mikethk
New php-forum User
New php-forum User
Posts: 6
Joined: Tue Oct 23, 2012 8:30 am

Re: Switching for ANSI to UTF-8 and Query syntex

Postby Mikethk » Thu Dec 05, 2013 10:58 am

You need this in <head>
<meta http-equiv="Content-Type" value="text/html; charset=ISO-8859-1">

And then you neda convert ANSI to UTF-8, not just save


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 3 guests