Jump to content

Recommended Posts

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>";

Link to comment
https://forums.phpfreaks.com/topic/146178-solved-output-array/
Share on other sites

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)

 

Link to comment
https://forums.phpfreaks.com/topic/146178-solved-output-array/#findComment-767448
Share on other sites

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).

Link to comment
https://forums.phpfreaks.com/topic/146178-solved-output-array/#findComment-767462
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/146178-solved-output-array/#findComment-767471
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.