Set the database charset in the UPDATE script so the conversions will actually work - that only took 8 hours to figure out!

This commit is contained in:
james 2009-12-03 20:55:16 +00:00
parent e51b7fc1b2
commit 684a7962f2
4 changed files with 14 additions and 14 deletions

View File

@ -728,12 +728,13 @@ case "email_get_list":
echo "</select>";
echo "</td></tr>";
echo "<tr><td><b>Date:</b></td><td>".date("r")."</td></tr>";
echo "<tr><td><b>Subject:</b></td><td>".htmlspecialchars(iconv("utf-8","ISO-8859-1",$r->subject))."</td></tr>";
echo "<tr><td><b>Subject:</b></td><td>".htmlspecialchars(iconv("UTF-8","ISO-8859-1//TRANSLIT",$r->subject))."</td></tr>";
if($r->bodyhtml) {
$body=iconv("utf-8","ISO-8859-1",$r->bodyhtml);
$body=iconv("UTF-8","ISO-8859-1//TRANSLIT",$r->bodyhtml);
}
else {
$body=nl2br(htmlspecialchars(iconv("UTF-8","ISO-8859-1//TRANSLIT",$r->body)));
}
else
$body=nl2br(htmlspecialchars(iconv("utf-8","ISO-8859-1",$r->body)));
echo "<tr><td colspan=2>".$body."</td></tr>";
@ -742,8 +743,7 @@ case "email_get_list":
if(!function_exists("exec")) {
echo "<div class=\"error\">Sending requires php's exec() function to be available</div>\n";
}
else
{
else {
echo "<table border=0 cellspacing=0 cellpadding=30 width=\"100%\">";
echo "<tr><td align=center>";
echo "<input type=hidden name=action value=\"reallysend\">";

View File

@ -3,16 +3,12 @@
function db_update_155_post() {
//we need to query the stuff from the table
$q=mysql_query("SELECT * FROM emails");
//make the changes to the database
mysql_query("ALTER TABLE `emails` CHANGE `body` `body` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
mysql_query("ALTER TABLE `emails` CHANGE `bodyhtml` `bodyhtml` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
mysql_query("ALTER TABLE `emails` CHANGE `subject` `subject` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
//then update the data
while($r=mysql_fetch_object($q)) {
echo "Updating email id $r->id\n";
mysql_query("UPDATE emails SET
body='".mysql_real_escape_string(iconv("ISO-8859-1","UTF-8",$r->body))."' ,
bodyhtml='".mysql_real_escape_string(iconv("ISO-8859-1","UTF-8",$r->bodyhtml))."' ,
subject='".mysql_real_escape_string(iconv("ISO-8859-1","UTF-8",$r->subject))."'
body='".mysql_real_escape_string(iconv("ISO-8859-1","UTF-8//TRANSLIT",$r->body))."' ,
bodyhtml='".mysql_real_escape_string(iconv("ISO-8859-1","UTF-8//TRANSLIT",$r->bodyhtml))."' ,
subject='".mysql_real_escape_string(iconv("ISO-8859-1","UTF-8//TRANSLIT",$r->subject))."'
WHERE id='$r->id'");
}
}

View File

@ -1,3 +1,6 @@
ALTER TABLE `emails` CHANGE `body` `body` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `emails` CHANGE `bodyhtml` `bodyhtml` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `emails` CHANGE `subject` `subject` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `emailqueue` CHANGE `body` `body` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `emailqueue` CHANGE `bodyhtml` `bodyhtml` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `emailqueue` CHANGE `subject` `subject` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;

View File

@ -22,6 +22,7 @@ else
mysql_connect($DBHOST,$DBUSER,$DBPASS);
mysql_select_db($DBNAME);
@mysql_query("SET NAMES latin1");
$q=mysql_query("SELECT val FROM config WHERE var='DBVERSION' AND year='0'");
$r=mysql_fetch_object($q);
$dbdbversion=$r->val;