Q695 Posted February 20, 2009 Share Posted February 20, 2009 Why is this outputting the word "Array": //project e-mailer//////////////////////////////////////////////// foreach ($contractor as $contractor){ $sql= "SELECT * FROM contractors WHERE id='$contractor' AND approve='0'"; $result=@mysql_query($sql,$con) or die($sql); $row=mysql_fetch_array($result); $to=$row[e_mail]; $subject = 'Construction Project'; $message=$project; $headers = 'From: keeptheweatherout@gmail.com' . "\r\n" . 'Reply-To: keeptheweatherout@gmail.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($to, $subject, $message, $headers); } //close out mailer echo "<a href='contact_firms.php'>Message successfully sent.</a><p></p>"; Quote Link to comment https://forums.phpfreaks.com/topic/146178-solved-output-array/ Share on other sites More sharing options...
cunoodle2 Posted February 20, 2009 Share Posted February 20, 2009 Are there any error messages if you remove the "@" from the mysql query line? What gets printed to the screen if you do this... echo "Row Email: --".$row[e_mail]."--"; (I use the "--" before and after the output for troubleshooting so I can see if in some cases it is outputting blank spaces. It has saved me a few times in the past) Quote Link to comment https://forums.phpfreaks.com/topic/146178-solved-output-array/#findComment-767448 Share on other sites More sharing options...
Q695 Posted February 20, 2009 Author Share Posted February 20, 2009 it is outputting the word "array" Quote Link to comment https://forums.phpfreaks.com/topic/146178-solved-output-array/#findComment-767455 Share on other sites More sharing options...
Mark Baker Posted February 20, 2009 Share Posted February 20, 2009 foreach ($contractor as $contractor) Do you mean to use $contractor for both the array and the individual entries in that array? Quote Link to comment https://forums.phpfreaks.com/topic/146178-solved-output-array/#findComment-767461 Share on other sites More sharing options...
premiso Posted February 20, 2009 Share Posted February 20, 2009 Where is $project being set? I fail to see that part. It echos out array because to print an array in a message you need to use print_r (with 1 for the 2nd parameter). You are "printing" an array like a string, which just prints array. Also note the foreach you use the same variable (I am surprised this works due to that). Quote Link to comment https://forums.phpfreaks.com/topic/146178-solved-output-array/#findComment-767462 Share on other sites More sharing options...
Q695 Posted February 20, 2009 Author Share Posted February 20, 2009 This should be simple, the word array is being printed somewhere, and I don't know where it is at. It sends the e-mail message properly, but displays the word array. The output to the screen is:Array Message successfully sent. in short: kill the word "array" that is printed to the screen. Quote Link to comment https://forums.phpfreaks.com/topic/146178-solved-output-array/#findComment-767471 Share on other sites More sharing options...
Philip Posted February 20, 2009 Share Posted February 20, 2009 Well, what's before: //project e-mailer//////////////////////////////////////////////// Quote Link to comment https://forums.phpfreaks.com/topic/146178-solved-output-array/#findComment-767472 Share on other sites More sharing options...
Q695 Posted February 20, 2009 Author Share Posted February 20, 2009 I feel so horrible, I didn't realize I was echoing contractors at the top of the page . Quote Link to comment https://forums.phpfreaks.com/topic/146178-solved-output-array/#findComment-767483 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.