blink359 Posted July 21, 2010 Share Posted July 21, 2010 I tried to use this code that i wrote after being told the while statement to use and got Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a9855336/public_html/massemail.php on line 38 Here is the code it includes the line numbers as this is not the full .php file as the rest of it is the ccs links etc 26 <form action="mail.php" method="post"> 27 <p>From:<br /> 28 <input type="text" name="from" />@example.co.uk<br /> 29 Subject:<br /> 30 <input type="text" name="subject" /><br /> 31 Message:<br /><textarea rows="10" cols="50" name="message" /></textarea><br /> 32 <input type="submit" /></p></form></p> 33 <? 34 $result = mysql_query("SELECT email FROM mail); 35 36 while ($row = mysql_query($result)) //this takes all email out of database and puts them in the "to" part 37 { 38 $to = '$row['email'] ,'; 39 40 $subject = $_POST['subject']; 41 $message = $_POST['message']; 42 $from = $_POST['from']@example.co.uk; 43 mail('$to', '$subject', '$message', null, 44 '-$from'); 45 46 ?> Thanks Blink359 Quote Link to comment Share on other sites More sharing options...
inversesoft123 Posted July 21, 2010 Share Posted July 21, 2010 Your line 38 should be $to = $row['email']; Quote Link to comment Share on other sites More sharing options...
blink359 Posted July 21, 2010 Author Share Posted July 21, 2010 In between each email address will it need a , to seperate each email address? Quote Link to comment Share on other sites More sharing options...
blink359 Posted July 21, 2010 Author Share Posted July 21, 2010 still get Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a9855336/public_html/massemail.php on line 39 even with $result = mysql_query("SELECT email FROM mail); while ($row = mysql_query($result)) { $to = $row['email']; Quote Link to comment Share on other sites More sharing options...
inversesoft123 Posted July 21, 2010 Share Posted July 21, 2010 Why you used @ in line number 42 ? while ($row = mysql_query($result)) //this takes all email out of database and puts them in the "to" part { $to = $row['email']; $subject = $_POST['subject']; $message = $_POST['message']; $mailid = $_POST['from']; $from = "$mailid@example.co.uk"; mail('$to', '$subject', '$message', null,'-$from'); Quote Link to comment Share on other sites More sharing options...
blink359 Posted July 21, 2010 Author Share Posted July 21, 2010 <? $result = mysql_query("SELECT email FROM mail); while ($row = mysql_query($result)) { $to = $row['email']; $subject = $_POST['subject']; $message = $_POST['message']; $from = $_POST['from']@example.co.uk; mail('$to', '$subject', '$message', null, '-$from'); ?> Say $_POST['from'] was blink359 i wanted to add @example.co.uk on the end thought it might work obviously not? Quote Link to comment Share on other sites More sharing options...
blink359 Posted July 21, 2010 Author Share Posted July 21, 2010 But that still doesnt explain the line 39 problem :S Quote Link to comment Share on other sites More sharing options...
inversesoft123 Posted July 21, 2010 Share Posted July 21, 2010 But that still doesnt explain the line 39 problem :S Have you checked my updated code? replace your email line with my 2 lines. $mailid = $_POST['from']; $from = "$mailid@example.co.uk"; Quote Link to comment Share on other sites More sharing options...
blink359 Posted July 21, 2010 Author Share Posted July 21, 2010 meh... my web host has different line numbers than the same code on dreamweaver >.< line 39 on my web host is while ($row = mysql_query($result)) <---- this part is still a problem Just trying the above now Quote Link to comment Share on other sites More sharing options...
inversesoft123 Posted July 21, 2010 Share Posted July 21, 2010 while ($row = mysql_fetch_array($result)) Now combine my corrections and it will work. Quote Link to comment Share on other sites More sharing options...
blink359 Posted July 21, 2010 Author Share Posted July 21, 2010 I wish it was working now so you didnt have to help me anymore but it isnt >.< i may have missed something Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a9855336/public_html/massemail.php on line 41 36 <? 37$mailid = $_POST['from']; 38 39$result = mysql_query("SELECT email FROM mail); 40 41while ($row = mysql_fetch_array($result)) 42{ 43$to = $row['email']; 44 45$subject = $_POST['subject']; 46$message = $_POST['message']; 47$from = "$mailid@example.co.uk"; 48mail('$to', '$subject', '$message', null, 49 '-$from'); 50 51?> Quote Link to comment Share on other sites More sharing options...
inversesoft123 Posted July 21, 2010 Share Posted July 21, 2010 Now carefully check your mysql query on line number 39 in your code i dont know about web server. $result = mysql_query("SELECT email FROM mail"); Quote Link to comment Share on other sites More sharing options...
blink359 Posted July 21, 2010 Author Share Posted July 21, 2010 STUPID me. God i fail!, i havent done a mysql_connect or mysql_select, thanks for your time anyway, you have spotted problems i would have come accross anyway! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.