GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 04-Aug-2003, 11:41
ukrspp21 ukrspp21 is offline
New Member
 
Join Date: Jul 2003
Location: London
Posts: 17
ukrspp21 is an unknown quantity at this point

Mail message with variables


Dear All

I am trying configure a function that will send a mail to my users informing them of their password. I would like it to include some information in the message like, name, title etc. My problem begins!!
The Error I am getting with my code is;

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/sites/site112/web/fp.php on line 20

The code is;

<?php
//connection functions etc.
require_once ('incl_funs.php');
do_header('Password Sent','Password<br/>Sent');
$username=$HTTP_POST_VARS['username'];
$email=$HTTP_POST_VARS['email'];
$subject=$HTTP_POST_VARS['subject'];
$fromaddress='p.robertson@boltd.co.uk';
do_db_connect();

$query = 'SELECT * from users, userdata WHERE (users.username= '.$username.') AND (users.username= userdata.username)';
$result = mysql_query($query);
$num_results=mysql_num_rows($result);
$row;
$row = mysql_fetch_array($result);

if ($email==$row['email']) {


//This line is showing the error
$mailcontent="Dear $row['salutation'] $row['fname']\r\n\r\n
Your password is $row['passwd']. May I recommend that change your password to something memorable by visiting www.boltd.co.uk
Best Regards \r\n
\r\n
Philip Robertson\r\n
BOLTd";






mail ($email,$subject,$mailcontent,$fromaddress);

}

Any suggestions from you gurus out there?
Cheers
Phil

p.s. I am not sure if this is the correct way to include code please let me know if there is a more approved of method for future ref.
  #2  
Old 05-Aug-2003, 04:57
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Just a quick observation here; perhaps it's related to your problem, perhaps not -

Inside double quotes:
PHP Code:

<?php

// will work
$mailcontent="Dear {$row['salutation']} {$row['fname']}\r\n\r\n";
// will also work
$mailcontent="Dear $row[salutation] $row[fname]\r\n\r\n";
// will also work
$mailcontent="Dear ".$row['salutation']." ".$row['fname']."\r\n\r\n";

// won't work
$mailcontent="Dear $row['salutation'] $row['fname']\r\n\r\n";
?>


Also quote the string(?) in the sql query?
PHP Code:

<?php
$query = 'SELECT * from users, userdata
         WHERE (users.username= "'.$username.'")
         AND (users.username= userdata.username)';
?>


re:quoting PHP code
Please view the FAQ to highlight PHP code (see the sample at the bottom of the page) in your posts.
  #3  
Old 05-Aug-2003, 05:10
ukrspp21 ukrspp21 is offline
New Member
 
Join Date: Jul 2003
Location: London
Posts: 17
ukrspp21 is an unknown quantity at this point
Cheers JDS

That was the exact problem I was having and your suggestion fixed it immediately. I get a bit confused about ' and ". I thought I had tried every combination of quotes and no quotes. Clearly I was mistaken!! I shall use the vB tags next time.

Once again

Thank you
Phil
 

Recent GIDBlogNARMY by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Free message board hosting, 30 skins, 11 languages. edkhosting Free Web Hosting 1 27-Feb-2004 13:14
Reliable Hosting $2-$8/month: PHP, MySQL, FrontPage, CGI, SSH, FTP, POP3, Web Mail fcolor Web Hosting Advertisements & Offers 0 04-Nov-2003 06:03
600MB Space, 20GB Banwidth, PHP, MySQL, CGI, SSH, FrontPage, FTP, POP3, Web Mail fcolor Web Hosting Advertisements & Offers 0 08-Aug-2003 10:11
E Mail Forwarding nikkotash Computer Software Forum - Windows 3 30-Jun-2003 03:20
PHP variables nniehoff MySQL / PHP Forum 7 26-Jul-2002 06:25

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:25.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.