Insert into $_session

Résolu
techinfo46 Messages postés 383 Date d'inscription   Statut Membre Dernière intervention   -  
techinfo46 Messages postés 383 Date d'inscription   Statut Membre Dernière intervention   -
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

le père
 
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   Statut Membre Dernière intervention   56
 
merci sa fonctionne
0