Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 04/01/2012, 14h01   #1
Invité de passage
 
Homme John Lito
Artisan
Inscription : janvier 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme John Lito
Localisation : Belgique

Informations professionnelles :
Activité : Artisan
Secteur : Santé

Informations forums :
Inscription : janvier 2012
Messages : 10
Points : 3
Points : 3
Par défaut concaténation chaîne de caractères : exclusion de certains caractères

Bonjour,

Pouvez-vous me dire pourquoi le test fonctionne et le résultat n’est pas identique en production ?

Je dois construire un lien url AUTOMATIQUEMENT : j’utilise concat (plusieurs champs dans un seul) avec PHPMyAdmin.

Code :
1
2
3
4
5
SELECT *, CONCAT(ContentPageName,'?',UPPER(SUBSTRING(ContentPageName,1,1)),LOWER(SUBSTRING(ContentPageName,2,length(ContentPageName)-5)),'=',ContentPageSetOrder) as linkurl
 
FROM pcms2_contents
 
WHERE ContentRefID = 'content'
VOIR Clipboard01.jpg > about.php?About=1

Mais en production j’ai ça : about.php?About.php=1 (le 2e .php est en trop ???)


voir Clipboard02.jpg > about.php?About.php=1

????

2,4 ne fonctionne pas non plus avec PHPMyAdmin


Code :
1
2
3
4
5
SELECT *, CONCAT(ContentPageName,'?',UPPER(SUBSTRING(ContentPageName,1,1)),LOWER(SUBSTRING(ContentPageName,2,4),'=',ContentPageSetOrder) as linkurl
 
FROM pcms2_contents
 
WHERE ContentRefID = 'content'

Merci
pour votre aide
Cordialement
John
Images attachées
Type de fichier : jpg Clipboard01.jpg (55,0 Ko, 3 affichages)
Type de fichier : jpg Clipboard02.jpg (40,7 Ko, 3 affichages)
johnlito est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2012, 14h29   #2
Modérateur
 
Avatar de CinePhil
 
Homme Philippe Leménager
Ingénieur d'études en informatique
Inscription : août 2006
Messages : 11 029
Détails du profil
Informations personnelles :
Nom : Homme Philippe Leménager
Âge : 48
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Ingénieur d'études en informatique
Secteur : Enseignement

Informations forums :
Inscription : août 2006
Messages : 11 029
Points : 18 331
Points : 18 331
Envoyer un message via MSN à CinePhil
Ta première requête est bonne. Es-tu sûr d'avoir la même requête en production ?
Ton code PHP ne triturerait-il pas quelque part la chaîne récupérée avant affectation de l'URL créée ?
__________________
Philippe Leménager. Ingénieur d'étude à l'École Nationale de Formation Agronomique.
Mon blog sur la conception des BDD, le langage SQL, le PHP avec Zend Framework...
« Ce que l'on conçoit bien s'énonce clairement, et les mots pour le dire arrivent aisément ». (Nicolas Boileau)
À la maison comme au bureau, j'utilise Mandriva Linux ou Mageïa ! Soutenons l'industrie logicielle française !
Linuxiens, comptez-vous !
CinePhil est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2012, 14h52   #3
Invité de passage
 
Homme John Lito
Artisan
Inscription : janvier 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme John Lito
Localisation : Belgique

Informations professionnelles :
Activité : Artisan
Secteur : Santé

Informations forums :
Inscription : janvier 2012
Messages : 10
Points : 3
Points : 3
Par défaut Verification code php

J'ai vérifié, j'affiche simplement la variable dans une boucle :

<?php echo $row_page_link['linkurl']; ?>
johnlito est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2012, 15h05   #4
Modérateur
 
Avatar de CinePhil
 
Homme Philippe Leménager
Ingénieur d'études en informatique
Inscription : août 2006
Messages : 11 029
Détails du profil
Informations personnelles :
Nom : Homme Philippe Leménager
Âge : 48
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Ingénieur d'études en informatique
Secteur : Enseignement

Informations forums :
Inscription : août 2006
Messages : 11 029
Points : 18 331
Points : 18 331
Envoyer un message via MSN à CinePhil
On peut voir ton code PHP ?
__________________
Philippe Leménager. Ingénieur d'étude à l'École Nationale de Formation Agronomique.
Mon blog sur la conception des BDD, le langage SQL, le PHP avec Zend Framework...
« Ce que l'on conçoit bien s'énonce clairement, et les mots pour le dire arrivent aisément ». (Nicolas Boileau)
À la maison comme au bureau, j'utilise Mandriva Linux ou Mageïa ! Soutenons l'industrie logicielle française !
Linuxiens, comptez-vous !
CinePhil est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2012, 15h32   #5
Invité de passage
 
Homme John Lito
Artisan
Inscription : janvier 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme John Lito
Localisation : Belgique

Informations professionnelles :
Activité : Artisan
Secteur : Santé

Informations forums :
Inscription : janvier 2012
Messages : 10
Points : 3
Points : 3
Par défaut voici le code PHP/sql

Le voici...

sql/php


Code :
1
2
3
4
5
6
7
8
9
10
11
12
mysql_select_db($database_PowerCMSConnection, $PowerCMSConnection);
$query_page_link = "SELECT *, CONCAT(ContentPageName,'?',UPPER(SUBSTRING(ContentPageName,1,1)),LOWER(SUBSTRING(ContentPageName,2,4)),'=',ContentPageSetOrder) as linkurl FROM pcms2_contents WHERE ContentRefID = 'content'";
$page_link = mysql_query($query_page_link, $PowerCMSConnection) or die(mysql_error());
$row_page_link = mysql_fetch_assoc($page_link);
$totalRows_page_link = mysql_num_rows($page_link);
$query_page_link = "SELECT *, CONCAT(ContentPageName,'?',UPPER(SUBSTRING(ContentPageName,1,1)),LOWER(SUBSTRING(ContentPageName,2)),'=',ContentPageSetOrder) as linkurl FROM pcms2_contents WHERE ContentRefID = 'content'";
$page_link = mysql_query($query_page_link, $PowerCMSConnection) or die(mysql_error());
$row_page_link = mysql_fetch_assoc($page_link);
$totalRows_page_link = mysql_num_rows($page_link);$colname_content = "-1";
if (isset($_GET['ContentID'])) {
  $colname_content = (get_magic_quotes_gpc()) ? $_GET['ContentID'] : addslashes($_GET['ContentID']);
}

body
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<table border="0" cellspacing="7">
  <tr>
    <td><strong>ContentID</strong></td>
    <td><strong>ContentGroup</strong></td>
    <td><strong>ContentDate</strong></td>
    <td><strong>Liens du menu</strong></td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_page_link['ContentID']; ?></td>
      <td><?php echo $row_page_link['ContentGroup']; ?></td>
      <td><?php echo $row_page_link['ContentDate']; ?></td>
      <td><?php 
// Show IF Conditional region4 
if (@$row_page_link['ContentPageSetOrder'] == "") {
?>
        <strong><?php echo $row_page_link['ContentPageName']; ?></strong>
        <?php } 
// endif Conditional region4
?>
        <?php 
// Show IF Conditional region5 
if (@$row_page_link['ContentPageSetOrder'] != "") {
?>
        <strong><?php echo $row_page_link['linkurl']; ?></strong>
        <?php } 
// endif Conditional region5
?></td>
    </tr>
    <?php } while ($row_page_link = mysql_fetch_assoc($page_link)); ?>
</table>
johnlito est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2012, 15h34   #6
Invité de passage
 
Homme John Lito
Artisan
Inscription : janvier 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme John Lito
Localisation : Belgique

Informations professionnelles :
Activité : Artisan
Secteur : Santé

Informations forums :
Inscription : janvier 2012
Messages : 10
Points : 3
Points : 3
Par défaut requete en double !!!

j'ai l'impression que ma requete comporte un doublon avec erreur et c'est le résultat de la derniere qui est affiché...

Merci
johnlito est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2012, 15h38   #7
Modérateur
 
Avatar de CinePhil
 
Homme Philippe Leménager
Ingénieur d'études en informatique
Inscription : août 2006
Messages : 11 029
Détails du profil
Informations personnelles :
Nom : Homme Philippe Leménager
Âge : 48
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Ingénieur d'études en informatique
Secteur : Enseignement

Informations forums :
Inscription : août 2006
Messages : 11 029
Points : 18 331
Points : 18 331
Envoyer un message via MSN à CinePhil
Exactement !
Tu lances deux fois la requête avec une légère différence. La seconde requête étant fausse par rapport à ton besoin, ton résultat est faux.
Si tu aérais un peu plus ton code, tu verrais mieux les erreurs.

La prochaine fois :


Et ici pense à
__________________
Philippe Leménager. Ingénieur d'étude à l'École Nationale de Formation Agronomique.
Mon blog sur la conception des BDD, le langage SQL, le PHP avec Zend Framework...
« Ce que l'on conçoit bien s'énonce clairement, et les mots pour le dire arrivent aisément ». (Nicolas Boileau)
À la maison comme au bureau, j'utilise Mandriva Linux ou Mageïa ! Soutenons l'industrie logicielle française !
Linuxiens, comptez-vous !
CinePhil est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2012, 15h41   #8
Invité de passage
 
Homme John Lito
Artisan
Inscription : janvier 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme John Lito
Localisation : Belgique

Informations professionnelles :
Activité : Artisan
Secteur : Santé

Informations forums :
Inscription : janvier 2012
Messages : 10
Points : 3
Points : 3
Par défaut Merci pour votre aide

Merci pour votre aide
johnlito est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 03h55.


 
 
 
 
Partenaires

Hébergement Web