Insert into $_session

Résolu/Fermé
techinfo46 Messages postés 383 Date d'inscription jeudi 23 décembre 2010 Statut Membre Dernière intervention 20 avril 2020 - 28 oct. 2011 à 17:53
techinfo46 Messages postés 383 Date d'inscription jeudi 23 décembre 2010 Statut Membre Dernière intervention 20 avril 2020 - 31 oct. 2011 à 12:01
Bonjour, voila mon script

$req_bailleur="INSERT INTO bailleur (NOMBAILLEUR_1,

PRENOMBAILLEUR_1,
ADRESSEBAILLEUR_1,
TELBAILLEUR_1,
FAXBAILLEUR_1,
VILLEBAILLEUR_1,
CODEPOSTALBAILLEUR_1,
MAILBAILLEUR_1)

(ligne20) VALUES('$_SESSION['BAILLEURPHYSIQUE'][$i]['nombailleur']',
'$_SESSION['BAILLEURPHYSIQUE'][$i]['prenombailleur']',
'$_SESSION['BAILLEURPHYSIQUE'][$i]['adressebailleur']',
'$_SESSION['BAILLEURPHYSIQUE'][$i]['telbailleur']',
'$_SESSION['BAILLEURPHYSIQUE'][$i]['faxbailleur']',
'$_SESSION['BAILLEURPHYSIQUE'][$i]['villebailleur']',
'$_SESSION['BAILLEURPHYSIQUE'][$i]['codepostalbailleur']',
'$_SESSION['BAILLEURPHYSIQUE'][$i]['mailbailleur']'

)";

et voici l'erreur

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files (x86)\EasyPHP-5.3.8.0\www\test7.php on line 20

2 réponses

Bonsoir

Régle d'écriture des chaînes en PHP :
Quand tu utilises une variable tableau dans une chaîne entre double quotes, il NE FAUT PAS mettre les simples quotes autour de l'indice
Autrement dit :
$req_bailleur="INSERT INTO bailleur (NOMBAILLEUR_1,
PRENOMBAILLEUR_1,
ADRESSEBAILLEUR_1,
TELBAILLEUR_1,
FAXBAILLEUR_1,
VILLEBAILLEUR_1,
CODEPOSTALBAILLEUR_1,
MAILBAILLEUR_1)
VALUES('$_SESSION[BAILLEURPHYSIQUE][$i][nombailleur]',
'$_SESSION[BAILLEURPHYSIQUE][$i][prenombailleur]',
'$_SESSION[BAILLEURPHYSIQUE][$i][adressebailleur]',
'$_SESSION[BAILLEURPHYSIQUE][$i][telbailleur]',
'$_SESSION[BAILLEURPHYSIQUE][$i][faxbailleur]',
'$_SESSION[BAILLEURPHYSIQUE][$i][villebailleur]',
'$_SESSION[BAILLEURPHYSIQUE][$i][codepostalbailleur]',
'$_SESSION[BAILLEURPHYSIQUE][$i][mailbailleur']'
)"; 

Dans le doute, tu peux toujours créer ta chaîne par concaténation, tu n'as plus besoin de te rappeler cette règle bizarre
0
techinfo46 Messages postés 383 Date d'inscription jeudi 23 décembre 2010 Statut Membre Dernière intervention 20 avril 2020 56
31 oct. 2011 à 12:01
merci sa fonctionne
0