note 49621 added to function.mysql-query
| From: | Shawn at osu1 dot php dot net | Date: | Thu, 03 Feb 2005 05:48:42 +0000 |
| Subject: | note 49621 added to function.mysql-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-84411@lists.php.net to get a copy of this message | ||
I am having problems with the results returned using mysql_query() when the database field contains
extended ASCII characters.
If I perform a query within mysql the text appears as expected, but if I do it from within php using
mysql_query() the extended ASCII characters are replaced with ? (question marks).
For example, from within mysql:
mysql>select * from items where stringID=4;
displays the string: Précédent
However, when I use the following PHP script:
<?php
$dbhost = "localHost";
$dbname = "mydb";
$dbuser = "mydbuser";
$dbpass = "mydbuserpassword";
$connection = mysql_pconnect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
$result = mysql_query("SELECT * FROM items WHERE stringID=4");
echo '<pre>';
echo 'result: ' . $result;
while ($row = mysql_fetch_array($result, MYSQL_BOTH))
{
printf("\nID: %s:%s String: %s", $row["stringID"],
$row["itemID"], $row["itemString"]);
}
mysql_free_result($result);
echo '</pre>';
?>
I get the following output:
ID: 4:13 String: Pr?c?dent
I would imagine the ?'s are UNICODE codes, but why don't they display?
----
Manual Page -- http://www.php.net/manual/en/function.mysql-query.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49621
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49621&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49621&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49621&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49621&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49621&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49621&report=yes
Search -- http://master.php.net/manage/user-notes.php