[SOLVED]user data is displayed as ???????,

13 years 8 months ago #136842 by emakki
Probably there is a utf-8 encoding somewhere in the code. This happened to me before in Arabic with one of the components.

For those who face the ??? question marks issue with utf. There is a solution script I found online that converts everything in the database to utf-8 including the fields. Just use the script and enter db connection information.

Make sure you save as index.php and upload to a new folder.

Good luck.


[code:1]
<html>
<head>
<style type="text/css">
body {background-color:#000; font-family:"Courier New", Courier, monospace; font-size:12px;color:#ffffff}
</style>
</head>
<body>
<?php
function start_db($mysqlhost,$mysqldatabase, $mysqluser, $mysqlpass)
{
global $conn;
$conn = mysql_connect($mysqlhost, $mysqluser, $mysqlpass);
if (!$conn)
{
echo '<a href="index.php">Back to the main site</a><br />';
die('Database error.');
}
$select = mysql_select_db($mysqldatabase, $conn);
if (!$select)
{
echo '<a href="index.php">Back to the main site</a><br />';
die('Database error.');
}
}
function end_db ($conn)
{
mysql_close($conn);
}

if ( isset($_POST)
&& isset($_POST)
&& isset($_POST)
&& isset($_POST)
&& isset($_POST))
{
$mysqlhost = $_POST;
$mysqluser = $_POST;
$mysqlpass = $_POST;
$mysqldatabase = $_POST;
$collation = $_POST;

start_db($mysqlhost,$mysqldatabase, $mysqluser, $mysqlpass);

//Start code from php.vrana.cz/ - Author - Jakub Vrana
function mysql_convert($query) {
echo $query . ' ... <span style="color:#26d92b">OK</span><br /> ';
return mysql_query($query);
}
mysql_convert("ALTER DATABASE $mysqldatabase COLLATE $collation"«»);
$result = mysql_query("SHOW TABLES"«»);
while ($row = mysql_fetch_row($result)) {
mysql_convert("ALTER TABLE $row[0] COLLATE $collation"«»);
$result1 = mysql_query("SHOW COLUMNS FROM $row[0]"«»);
while ($row1 = mysql_fetch_assoc($result1)) {
if (preg_match('~char|text|enum|set~', $row1["Type"])) {
mysql_convert("ALTER TABLE $row[0] MODIFY $row1[Field] $row1[Type] CHARACTER SET binary"«»);
mysql_convert("ALTER TABLE $row[0] MODIFY $row1[Field] $row1[Type] COLLATE $collation" . ($row1["Null"] ? "" : " NOT NULL"«») . ($row1["Default"] && $row1["Default"] != "NULL" ? " DEFAULT '$row1[Default]'" : ""«»));
}
}
}
mysql_free_result($result);
//End code from php.vrana.cz/ - Author - Jakub Vrana
end_db($conn);
echo '<br /><a href="index.php">Back to the main page</a>';
}
else
{
?>
<h2> CHANGE DATABASE COLLATION (DATABASE, TABLES, COLUMNS)</h2>
<form action="index.php" method="post">
DB Host:______<input type="text" name="host" value="localhost" /><br />
DB User:______<input type="text" name="user" value="root" /><br />
DB Password:__<input type="password" name="pass" value="pass" /><br />
DB Name:______<input type="text" name="name" value="jos" /><br />
DB Collation:_<input type="text" name="col" value="utf8_general_ci" /><br />
______________<input type="submit" value="Submit" />
</form>
<?php
}
?>
</body>
</html>

[/code:1]

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.164 seconds

Facebook Twitter LinkedIn