PDA

View Full Version : Special Character Php Help



unkempt
April 18th, 2008, 05:55 PM
Hi - sorry if i am new to php

I am using flash 8 and i am grabbing data from mySql using php to feed flash.
My data has special characters in it (éö etc)

I have embedded these characters in flash but the data is not displaying correctly.
I have been told that urlencode in my php will help

This is my php function tht calls the data - how can i url encode all the data that is returned?

Note: i use several functions which are almost identical to this in my php, which basically grab all data from each field in a table - so i need all the data which is held in an array to be urlencoded - the letters needed to be encoded are éöÉÖ

HÖPE YÖU CAN HÉLP


function getAllArtists ($live) {
// Create SQL statement
$sql = sprintf("SELECT * FROM artists WHERE live = '%s';",
$live);
// Trace the query in the NetConnection debugger
//NetDebug::trace($sql);
// Run query on database
$result = mysql_query($sql);

$return = Array();
while($row=mysql_fetch_object($result)) {
$row->last_updated = $this->datetime_mysql_to_mysoup($row->last_updated);
array_push($return, $row);
}
return $return;
}

chrisclick
April 19th, 2008, 03:54 AM
ok, If I'm right. you do it like this:



return urlencode($return);

Voetsjoeba
April 19th, 2008, 05:16 AM
Flash expects its incoming data to be UTF-8 encoded. That means that whatever you feed it from PHP has to be encoded in UTF-8 as well. The way to do that is to set the connection charset (don't be mistaken, it's not any of the server charsets; MySQL will convert whatever charset the data is in to the connection charset before sending it).

The problem is that PHP connects to MySQL using the ISO-8859-1 aka ISO-Latin1 charset by default, and that this default setting isn't very easy to change (requires changing some values manually in my.cnf). However, what you can do is connect as ISO-Latin1, but then with your first query tell MySQL to send all future results as UTF-8 using the query SET NAMES 'utf8'.

So send that as your very first query and try again; your characters should show up in Flash correctly (if your font supports them of course).

svpriyan
April 19th, 2008, 05:19 AM
Dear Sir,
I am priyan from Netherlands,
I am referring your site to do my assignment in XML.
Actually i am doing a Querying in XML Database and i have to use PHP for the Querying interface,
I wanted to get some hints or help from you to do this task.
i am going to cite your site for my assignment which might help my peer reviewrs to follow you site in future too.
I have my xml file with data. now i have an PHp interface, which has the querying with Xpath/Xquery.
I could not continue with this, because i di dnot still get into the topic how i can do this with PHP.
If you could give me a simple example of "how to do a Xpath/Xquery with Xml data with PHP.
selecting the names of the customers--
I will be able to think / develop it in more "

Please help me sir.

Thanks
Priyan
svpriyan@gmail.com