473,651 Members | 2,987 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Charset trouble

matheussousuke
249 New Member
Hi guys, good morning.

I've just get this script for converting mysql tables from wordpress, and I want to use it in my server, but no with wordpress, with oscommerce, a friend of mine told me a few things I should do for make it working, but less than a rookie in PHP, began studying it now ¬¬", and sure I dont know how to use command line yet, she told me something about using command line along with FTP ascii table, I'm lost, couldn't do that, how do I install it? How do I configurate it?

Ps: the script is for converting ascii characters for utf-8 or latin1. If u have anything else that can help me instead of using it, please let me know, here u see how's oscommerce http://www.mghospedagem.com/catalog/
u can see on the left that there are strange characters (oscommerce chars configuration is correct, the trouble's with the server, I contacted em but they didn't nothing, that's why I'm trying to install this script)

Here goes the script "convert_to_utf 8_sql_generator _extended.txt"

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. /*
  3. Template Name: Convert Database to UTF8 
  4.  
  5. Copyright 2007  Anders Stalheim Oefsdahl  (email : anders@apt.no)
  6. Detail at http://www.mydigitallife.info/2007/07/22/how-to-convert-character-set-and-collation-of-wordpress-database/
  7.  
  8. Bug fix by My Digital Life on 22 June 2007.
  9.  
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2 of the License, or
  13. (at your option) any later version.
  14.  
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. GNU General Public License for more details.
  19.  
  20. You should have received a copy of the GNU General Public License
  21. along with this program; if not, write to the Free Software
  22. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  23.  
  24. */
  25.  
  26. echo '<h1>Convert Database to UTF8</h1>';
  27.  
  28. echo '<p>This script generates SQL to convert existing tables to utf8, following the guide at <a href="http://codex.wordpress.org/Converting_Database_Character_Sets">http://codex.wordpress.org/Converting_Database_Character_Sets</a>, temporarily setting various fields to BLOB before setting them back to their respective types.</p>';
  29. echo '<p>This is an extended script for databases which are already utf8 but the strings are in latin1. It converts existing tables and colums to latin1 before the BLOB conversion</p>';
  30. echo '<p>Please note that you probably will get some errors running the scripts, regarding key length on some tables. These errors can be ignored (at least I did :).</p>';
  31.  
  32. require_once("wp-config.php");
  33. global $wpdb;
  34.  
  35. /**
  36.  * Fetch all tables
  37.  */
  38. $tables = array();
  39. $sql_tables = "SHOW TABLES";
  40. $res_tables = $wpdb->get_results( $sql_tables );
  41. if( is_array( $res_tables ) ){
  42.     foreach( $res_tables as $res_table ){
  43.         if(strpos($res_table->Tables_in_DATABASENAME, $table_prefix) === 0)
  44.         $tables[$res_table->Tables_in_DATABASENAME] = array();
  45.     }
  46. }
  47. /**
  48.  * Loop all tables fetching each table's fields and filter out fields of type CHAR, VARCHAR, TEXT, ENUM, and SET (and related variations)
  49.  */
  50. if( count( $tables )>0 ){
  51.     foreach( $tables as $table=>$fields ){
  52. //        if (strpos($table_prefix, $table) == 0)
  53. //        {
  54.             $sql_fields = "EXPLAIN ".$table;
  55.             $res_fields = $wpdb->get_results( $sql_fields );
  56.             if( is_array( $res_fields ) ){
  57.                 foreach( $res_fields as $field ){
  58.                     switch( TRUE ){
  59.                         case strpos( strtolower( $field->Type ), 'char' )===0:
  60.                         case strpos( strtolower( $field->Type ), 'varchar' )===0:
  61.                         case strpos( strtolower( $field->Type ), 'text' )===0:
  62.                         case strpos( strtolower( $field->Type ), 'enum' )===0:
  63.                         case strpos( strtolower( $field->Type ), 'set' )===0:
  64.                         case strpos( strtolower( $field->Type ), 'tinytext' )===0:
  65.                         case strpos( strtolower( $field->Type ), 'mediumtext' )===0:
  66.                         case strpos( strtolower( $field->Type ), 'longtext' )===0:
  67.                             $tables[$table][$field->Field] = $field->Type;
  68.                             break;
  69.  
  70.                         default:
  71.                             break;
  72.                     }
  73.                 }
  74. //            }
  75.         }
  76.     }
  77. }
  78.  
  79. $tables_to_latin1    = '';
  80. $tables_to_utf8        = '';
  81. $columns_to_latin1    = '';
  82. $columns_to_blob    = '';
  83. $columns_to_utf8    = '';
  84.  
  85. foreach( $tables as $table=>$fields ){
  86.     $tables_to_latin1 .= "\nALTER TABLE ".$table." DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;";
  87.     $tables_to_utf8 .= "\nALTER TABLE ".$table." DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;";
  88.     if( count( $fields )>0 ){
  89.         foreach( $fields as $name=>$type ){
  90.             $columns_to_latin1 .= "\nALTER TABLE ".$table." MODIFY ".$name." CHARACTER SET latin1 COLLATE latin1_swedish_ci;";
  91.             $columns_to_blob .= "\nALTER TABLE ".$table." MODIFY ".$name." BLOB;";
  92.             $columns_to_utf8 .= "\nALTER TABLE ".$table." MODIFY ".$name." ".$type.";";
  93.         }
  94.     }
  95. }
  96.  
  97. //$complete_sql = $sql_to_blob."\nALTER DATABASE ".DB_NAME." charset=utf8;".$sql_to_utf8.$sql_to_original;
  98. $complete_sql = $tables_to_latin1."\n".$columns_to_latin1."\n".$columns_to_blob."\n".$tables_to_utf8."\n".$columns_to_utf8;
  99.  
  100. echo nl2br( $complete_sql );
  101.  
  102. ?>
Oct 13 '09 #1
5 2430
Markus
6,050 Recognized Expert Expert
This seems like overkill. You might just change the content-type header of the page to something like: ISO-8859-1.

Expand|Select|Wrap|Line Numbers
  1. <head>
  2.  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  3. </head>
  4. <body>
  5. ...
  6.  
Oct 13 '09 #2
matheussousuke
249 New Member
Sorry, but...
I already did it =/
Oct 13 '09 #3
Markus
6,050 Recognized Expert Expert
Try 'utf-8'.
Oct 13 '09 #4
matheussousuke
249 New Member
It doesn't works, I tried both. That friend of mine told me that the trouble is with the server, that I should install a script that correct that. She did it in her server, made a script and it worked,
I asked if she could handle me the script but she sad she spent hours making it, now I found that one on the internet, shown her and she said that it will work if I install it corretly, she tryied to teach me how to install and configurate but dindt has too much time, she has been pretty busy.
Oct 13 '09 #5
matheussousuke
249 New Member
Anyone?

...

...

...
Oct 14 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1552
by: LMachado1 | last post by:
I just started with php and I'm trying to make a simple interface as follows: - user is asked to input an integers, for example: how many students do you want to enter? - user is then shown a page with number of text boxes = number he gave at the previous page - user fills out the test boxes with names of students and clicks submit - the user is sent to another page where the above names are output to
9
1612
by: Jakle | last post by:
I'm trying to write a program (with my very limited knowledge of python) that will convert text I type into those letters drawn with ascii symbols. I did 2 letters then went to test it. Here's the code I have so far: ******************************************* def S(): print " ________ " print " /--------\ " print "// \\" print "|| ^^"
37
3946
by: Haines Brown | last post by:
I understand that <br /> is marginal in CSS, and so am looking for a substitute for the EOL character. I've failed in both approaches and seek advice. The first thing I tried was to use the unicode EOL characer, which is 000A. I figured with was 10 in decimal notation, and so tried: line 1 line 2 No go. What was wrong with my thinking here?
1
15577
by: stevelooking41 | last post by:
Can someone explain why I don't seem unable to use document.write to produce a valid UTF-8 none breaking space sequence (Hex: C2A0) ? I've tried everyway I've been able to find to tell the browser I'm trying to print UTF-8 and still no luck. I'd like the first 2 tries to match the second two tries as far as output. <HTML> <meta http-equiv="Content-Type" content="application/x-script; charset=UTF-8">
6
3783
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory†exception. To get an idea what happens I traced some values using performance monitor and got the following values (for one day): \\FFDS24\ASP.NET Applications(_LM_W3SVC_1_Root_ATV2004)\Errors During Execution: 7 \\FFDS24\ASP.NET Apps v1.1.4322(_LM_W3SVC_1_Root_ATV2004)\Compilations
3
5739
by: Michael | last post by:
Hi all, I'm having trouble PInvoking a TCHAR within a struct. I'll paste the specific struct's API definition below. I've tried so many numerous variations. The main Win32 error I get is 0x3f0 / 515L which amounts to ERROR_NO_TOKEN. Every single instance of this in the past was due to mistakes I made while within PInvoked structs. Is anybody able to point me to documentation or just tell me outright how to
1
2048
by: Marc Scheuner | last post by:
Folks, we're trying to stream back a result set from a SQL query into Excel from our ASP.NET application. Basically, we're doing this here: Response.ContentType = "text/csv"; Response.Charset = "utf-8";
2
1461
by: Torsten Bronger | last post by:
Hallöchen! I thought that with the following code snippet, I could generate a MIME email stub: #!/usr/bin/env python # -*- coding: utf-8 -*- from email.MIMEText import MIMEText from email.Generator import Generator import sys
8
1933
by: cutlass | last post by:
Need you assistance to anyone who is willing to offer. I have been working on this script and can't get it to work. The issue I'm having is the statement: function validateSender($Address) { if (strpos($Address, '@') !== FALSE && strpos($Address, '.') !== FALSE) { return true; } else if (validateSender($_GET) == false) {
0
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5615
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.