Probleme d'insertion dans la base

Invité
Invité n'ayant pas de compte PHPfrance

21 mai 2006, 15:30

Bonjour,
j'ai un soucis lorque j'insere un texte dans ma base de donnee.
Elle fonctionne quand je tape un texte directement dans ma boite de saisie mais si je colle un texte a la place j'ai une erreur :

Code : Tout sélectionner

INSERT INTO dailyn( iddailyn, titredailyn, textedailyn ) VALUES ( '', 'THE STEELE FOUNDATION Opens Its IP Enforcement Practice in Shanghai', 'Companies Are Struggling to Better Understand How to Protect Their Intellectual Property SAN FRANCISCO, May 16 /PRNewswire/ -- THE STEELE FOUNDATION has announced that it has expanded its presence in China beyond Beijing and Hong Kong and opened an office in Shanghai, which is a WOFE (Wholly Foreign Owned Enterprise), to help combat the increasing threats to brand integrity and foreign investment. This is in conjunction with the past year's unprecedented commercial development IN this country 's largest city. "We have a long-established history of being a full-service risk management service provider to our clients in China. This expansion and establishment reflects Steele's further commitment TO a longterm presence IN China AND the issue of brand protection.We see a tremendous amount of business moving FROM Hong Kong TO Shanghai wherein Shanghai has become a critical commercial center FOR China 's economic development and for western firms," said Kenn Kurtz, Chief Executive Officer for THE STEELE FOUNDATION. "In 2010 the city plays host to the World Expo, the first city in the developing world to do so and only two years after Beijing hosts the Olympics. On a recent visit to Shanghai it was evident that this city is distinguishing itself as the future business capital of Asia and will not be overshadowed by the upcoming Olympics." With just over one percent of China's population, Shanghai accounts FOR more than five percent of China 's GDP. Add in the surrounding provinces of Jiangsu, Anhui and Zhejiang -- Shanghai's manufacturing region

MySQL a répondu:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's unprecedented commercial development in this country's largest city. "We have ' at line 1


Si vous saviezd'ou ca peux venir?

Bonne journee

ViPHP
ViPHP | 3607 Messages

21 mai 2006, 15:40

ça vient du fait que tu ne "protège" pas l'insertion, c.a.d qu'il y a peut-être eds quotes ou des doubles quotes dans ton texte copier coller, qui chamboules la sintaxe, essaye d'utiliser addslashes()

Modérateur PHPfrance
Modérateur PHPfrance | 7636 Messages

21 mai 2006, 16:00

C'est bien un problème d'échappement des apostrophes qui sera résolu avec la proposition de jojolapine.


Le message d'erreur de Mysql indique exactement l'endroit:
syntax to use near 's unprecedented
donc juste avant le "s" la où il y a une apostrophe.

Ceci vient du fait que tu ouvres la chaine de caratères avaec un ' et l'apostrophe du texte est considérée comme fermante et donc le reste est hors "chaine".... voila pour les petites explication :wink:

/!\ Avant de poster se documenter et rechercher.
Qui ne sait pas rendre un service n'a pas le droit d'en demander.
MaBrute

Invité
Invité n'ayant pas de compte PHPfrance

22 mai 2006, 08:22

MERCII