Jump to content

[SOLVED] output "Array"


Q695

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: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.