Archive for the 'MySQL' Category

18
Oct

Mysql + tableaux

Compteur

if (count($TABLEAU)>0):
ksort($TABLEAU);
While (List($KEY,$VALUE)=each($TABLEAU)):
echo (”$KEY -> $VALUE”);
EndWhile;
Endif;

Les tableaux php
_______________________

# connection SQL et ouverture de la base

mysql_connect(”localhost”,”root”,”");

mysql_select_db(”test”);
$res = mysql_query(”select distinct anneR from bfone order by anneR “) ;
$nbans = 0 ;
while ($ligr=mysql_fetch_array($res)) {
$nbans++ ; $ans[$nbans] = $ligr["anneR"] ;
} ; # fin de tant que

A Problèmes et erreurs communes MySQL 5.0.0 alpha

15
Oct

Client-side and Server-side encoding

Récupérer les accents français quand MySql parle latin… au lieu de UTF-8

Apache Server 2.0.54
PHP 5.0.4
MySQL 4.1.12
and WordPress 1.5.1.3

The problem all originates from MySQL 4.1

version 4.1 MySQL supports different language encodings

problem : “Client” encoding language and the “Server” encoding language.

The “Client” was set to Latin-1 encoding
The “Server” was set to UTF-8

“MySQL tries to translate from one language to the other when it puts the information in its Database. The problem is, my WordPress encoding already was UTF-8. So MySQL basically took UTF-8 encoded text (from WordPress) and treated it as Latin-1 encoded text and tried to convert it to UTF-8. Doing that, some characters where fine but more complex ones where not…

To solve this problem, you have to tell MySQL to treat all the stuff from WordPress as UTF-8 stuff.

First open the file: wordpress\wp-includes\wp-db.php

Find line 56, it should read as this:
$this->select($dbname);

Go to the beginning of the line and punch “enter” to make it move one line down and leave a blank line on line 56.

Then place this line at line 56:
$this->query(”SET NAMES ‘utf8′”);

Then your lines should look like this:
56 $this->query(”SET NAMES ‘utf8′”);
57 $this->select($dbname);

“now have a wordpress that can display and retain text in any language your computer can write in :)”

One final note, your Database must be a UTF-8 Database and your WordPress encoding must be UTF-8 also. For wordpress, you can find this in Options/Reading.

Japanese Characters not displaying right!

The patch we found that seems to have worked for some people but not for others was to add the line $this->query (”SET NAMES ‘utf8′”); after line 43 in wp-db.php.
http://wordpress.org/support/topic/48459?replies=6

PHP, MySQL 4.1 and UTF-8

09
Oct

Character Encoding + Transformation

After the damage has occured, the best way, it seems, to clean this up is to run multiple SQL queries in the phpmyadmin console emulating find/replace on the wp_posts table:

UPDATE wp_posts SET post_content = replace(post_content, “bad”, “good”)

Gestion des accents français

1/ exporter sous MySQL dans le bon encodage (sous wordpress, généralement UTF-8).

2/ encodage correct des accents dans les fichiers :

wp_posts, wp_comments, link_categories etc

update wp_posts set post_title=replace(post_title,“é”,“é”);
update wp_posts set post_title=replace(post_title,“Ô,“à”);
update wp_posts set post_title=replace(post_title,“ઔ,“ê”);
update wp_posts set post_title=replace(post_title,“à´”,“ô”);
update wp_posts set post_title=replace(post_title,“࢔,“â”);
update wp_posts set post_title=replace(post_title,“ਔ,“è”);
update wp_posts set post_title=replace(post_title,“௔,“ï”);
update wp_posts set post_title=replace(post_title,“à®”,“î”);
update wp_posts set post_title=replace(post_title,“à©”,“é”);
update wp_posts set post_title=replace(post_title,“à»”,“û”);
update wp_posts set post_title=replace(post_title,“à§”,“ç”);

update wp_posts set post_content=replace(post_content,“é”,“é”);
update wp_posts set post_content=replace(post_content,“Ô,“à”);
update wp_posts set post_content=replace(post_content,“ઔ,“ê”);
update wp_posts set post_content=replace(post_content,“à´”,“ô”);
update wp_posts set post_content=replace(post_content,“࢔,“â”);
update wp_posts set post_content=replace(post_content,“ਔ,“è”);
update wp_posts set post_content=replace(post_content,“௔,“ï”);
update wp_posts set post_content=replace(post_content,“à®”,“î”);
update wp_posts set post_content=replace(post_content,“à©”,“é”);
update wp_posts set post_content=replace(post_content,“à»”,“û”);
update wp_posts set post_content=replace(post_content,“à§”,“ç”);

migration : http://codex.wordpress.org/Moving_WordPress (english)

page en français : Migration wordpress un guide pas à pas pour votre migration. (revolunet)

Transition vers WordPress 2.0.4 et transformation d’une base de données iso-8859-15 au format UTF-8 Wireless

Redirection

Redirection par un fichier .htaccess à la racine du blog sur xxx.domaine.fr/wordpress :

RedirectMatch permanent /wordpress/(.*) http://newsite.com/$1

WordPress 2.0 Upgrade Problems: Character Encoding + Transformation

Blogs Imported (categories)

25
Sep

MySql relation table

How can I use the relation table in Query-by-example?

Here is an example with the tables persons, towns and countries, all located in the database mydb. If you don’t have a pma_relation table, create it as explained in the configuration section. Then create the example tables:

CREATE TABLE REL_countries (
country_code char(1) NOT NULL default ”,
description varchar(10) NOT NULL default ”,
PRIMARY KEY (country_code)
) TYPE=MyISAM;

INSERT INTO REL_countries VALUES (’C', ‘Canada’);

CREATE TABLE REL_persons (
id tinyint(4) NOT NULL auto_increment,
person_name varchar(32) NOT NULL default ”,
town_code varchar(5) default ‘0′,
country_code char(1) NOT NULL default ”,
PRIMARY KEY (id)
) TYPE=MyISAM;

INSERT INTO REL_persons VALUES (11, ‘Marc’, ‘S’, ”);
INSERT INTO REL_persons VALUES (15, ‘Paul’, ‘S’, ‘C’);

CREATE TABLE REL_towns (
town_code varchar(5) NOT NULL default ‘0′,
description varchar(30) NOT NULL default ”,
PRIMARY KEY (town_code)
) TYPE=MyISAM;

INSERT INTO REL_towns VALUES (’S', ‘Sherbrooke’);
INSERT INTO REL_towns VALUES (’M', ‘Montréal’);

To setup appropriate links and display information:

* on table “REL_persons” click Structure, then Relation view
* in Links, for “town_code” choose “REL_towns->code”
* in Links, for “country_code” choose “REL_countries->country_code”
* on table “REL_towns” click Structure, then Relation view
* in “Choose field to display”, choose “description”
* repeat the two previous steps for table “REL_countries”

Then test like this:

* Click on your db name in the left frame
* Choose “Query”
* Use tables: persons, towns, countries
* Click “Update query”
* In the fields row, choose persons.person_name and click the “Show” tickbox
* Do the same for towns.description and countries.descriptions in the other 2 columns
* Click “Update query” and you will see in the query box that the correct joins have been generated
* Click “Submit query”

29
Apr

Page numbering




 

August 2008
M T W T F S S
« Apr    
 123
45678910
11121314151617
18192021222324
25262728293031

Recent Comments