Jump to content

[SOLVED] mail function with multiple variables


dannau

Recommended Posts

Dear all,

 

I'm a beginner in PHP coding. I´ve made a form that connects to a Mysql database and an echo function of all the inormation. I'm tyrying to include a mail function that sends all the variables on our email address. It works flawlessly when I use only one variable, but is stuck with a T_variable message when I use more than one variable:

 

This is the code as I have it now:

$message = "Recu informations qualité de "$nom" pour le voyage effectué en "$mois" "$annee". \n\n Contact: "$contact", \n Supports: ".$supports.", \n Logements: "$logements", \n Circuit: "$circuit", \n Excursions: "$excursions", \n Guides: "$guides", \n Repas: "$repas", \n Transports: "$transports", \n Note: "$note", \n Commentaire: "$commentaire;
mail('my email@name.com', 'Retour de Questionnaire Qualite',$message);

 

This is probably a very basic and stupid mistake (I hope) but I have been working on this for a whole day.

 

Thanks,

 

Mark (Mantagua, Chile)

Link to comment
Share on other sites

Your error is here: "$logements", \n Circuit: "$circuit",

 

You need to concatenate there

 

try this :

$message = "Recu informations qualité de " .$nom. " pour le voyage effectué en " .$mois. " " .$annee. ". \n\n Contact: " .$contact. ", \n Supports: " .$supports. ", \n Logements: " .$logements. ", \n Circuit: ". $circuit. ", \n Excursions: " .$excursions. ", \n Guides: " .$guides. ", \n Repas: " .$repas. ", \n Transports: " .$transports. ", \n Note: " .$note. ", \n Commentaire: " .$commentaire. "";

 

Or if you want the quotes to appear around the variables, preceed them with a backslah... example qualité de \"$nom\"

Link to comment
Share on other sites

Thank you Suttercain.

 

I tried the new code and I still get the same message: Parse error: syntax error, unexpected T_VARIABLE in /home/dannau/public_html/qual/insert.php on line 41

 

Mark (Mantagua Chile)

Link to comment
Share on other sites

 

 

I'm very proud of myself because I found the solution on my own.

 

I've started using snippets of the message and they would all work separately. That's until I added the part where two variables are one behind the other. I just added a short word in between and it works.

 

Before:

$message = "Recu informations qualité de " .$nom. " pour le voyage effectué en " .$mois. " " .$annee. ". \n\n Contact: " .$contact. ", \n Supports: " .$supports. ", \n Logements: " .$logements. ", \n Circuit: ". $circuit. ", \n Excursions: " .$excursions. ", \n Guides: " .$guides. ", \n Repas: " .$repas. ", \n Transports: " .$transports. ", \n Note: " .$note. ", \n Commentaire: " .$commentaire. "";

 

After:

$message = "Recu informations qualité de " .$nom. " pour le voyage effectué en " .$mois. " de " .$annee. ". \n\n Contact: " .$contact. ", \n Supports: " .$supports. ", \n Logements: " .$logements. ", \n Circuit: ". $circuit. ", \n Excursions: " .$excursions. ", \n Guides: " .$guides. ", \n Repas: " .$repas. ", \n Transports: " .$transports. ", \n Note: " .$note. ", \n Commentaire: " .$commentaire. "";

 

Does someone send me a chocolate medal now?

 

Cheers,

 

Mark

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.