NameSilo

Np$ 50 for resolving issue.

SpaceshipSpaceship
Watch

fried-chicken

Established Member
Impact
5
keep getting this error message:


Warning: mail(): SMTP server response: 554 Error: no valid recipients in e:\domains\c\cheap-florida-holiday.com\user\htdocs\email.php on line 25


anyone help me?
Np$ 50 for resolving issue.

cheers
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
PoorDoggie said:
ps: what does the "@" sign before the mail() function do?
@ in front of a PHP function supress any error returned by the function.
 
0
•••
Made a few changes:
PHP:
<?

require_once("conn.php");
require_once("includes.php");

$q1 = mysql_query("SELECT * FROM re2_agents WHERE AgentID = '".intval($_GET['AgentID'])."'") or die(mysql_error());
$a1 = mysql_fetch_array($q1);

if(isset($_POST['s1']))
{
  $to = $a1['email'];
  $subject = $_POST['subject'];
  $message = $_POST['message'];
  $message .= 'Property:'."\n".$site_url.'/info.php?id='.intval($_GET['ListingID'])."\n\n";

  $headers .= 'Content-type: text/plain; charset=iso-8859-1'."\r\n";
  $headers .= 'Content-Transfer-Encoding: 8bit'."\r\n";
  $headers .= 'From: '.$_POST['u_name'].' <'.$_POST['u_email'].'>'."\r\n";

  if(!@mail($to, $subject, $message, $headers))
  {
    echo "error";
  }
  $thankyou = '<center><b><br><br><br>Thank you for your message!<br><br><a class=RedLink href="'.$site_url.'/info.php?id='.intval($_GET['ListingID']).'">back to the property details</a></center>';

  require_once("templates/HeaderTemplate.php");
  require_once("templates/EmailThankyouTemplate.php");
  require_once("templates/FooterTemplate.php");
}

$AgentName = $a1['FirstName'].' '.$a1['LastName'];

if(!empty(intval($_GET['ListingID'])))
{
  $SubjectLine = "Property ID ".intval($_GET['ListingID']);
}

require_once("templates/HeaderTemplate.php");
require_once("templates/EmailTemplate.php");
require_once("templates/FooterTemplate.php");

?>
I'll also point out, you might want to implement some input validation. ;)
 
0
•••
Constantin said:
@ in front of a PHP function supress any error returned by the function.
oh right :) so if I were to do @mysql_query($sql) it wouldn't come up with lines of unintelligible text about me having an "error in [my] mysql syntax"?

Great, thanks.

Back to the thread
Tom
 
0
•••
i keep getting this error now on page load.

Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE or '$' in e:\domains\c\cheap-florida-holiday.com\user\htdocs\email.php on line 33
 
0
•••
bump
 
0
•••
please post the code again, it is a syntax error now.
 
0
•••
hi,

it all here.

<?

require_once("conn.php");
require_once("includes.php");

$q1 = mysql_query("SELECT * FROM re2_agents WHERE AgentID = '".intval($_GET['AgentID'])."'") or die(mysql_error());
$a1 = mysql_fetch_array($q1);

if(isset($_POST['s1']))
{
$to = $a1['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$message .= 'Property:'."\n".$site_url.'/info.php?id='.intval($_GET['ListingID'])."\n\n";

$headers .= 'Content-type: text/plain; charset=iso-8859-1'."\r\n";
$headers .= 'Content-Transfer-Encoding: 8bit'."\r\n";
$headers .= 'From: '.$_POST['u_name'].' <'.$_POST['u_email'].'>'."\r\n";

if(!@mail($to, $subject, $message, $headers))
{
echo "error";
}
$thankyou = '<center><b><br><br><br>Thank you for your message!<br><br><a class=RedLink href="'.$site_url.'/info.php?id='.intval($_GET['ListingID']).'">back to the property details</a></center>';

require_once("templates/HeaderTemplate.php");
require_once("templates/EmailThankyouTemplate.php");
require_once("templates/FooterTemplate.php");
}

$AgentName = $a1['FirstName'].' '.$a1['LastName'];

if(!empty(intval($_GET['ListingID'])))
{
$SubjectLine = "Property ID ".intval($_GET['ListingID']);
}

require_once("templates/HeaderTemplate.php");
require_once("templates/EmailTemplate.php");
require_once("templates/FooterTemplate.php");

?>
 
0
•••
bump
 
0
•••
PHP:
<?

require_once("conn.php");
require_once("includes.php");

//Move to vars, easier to work with.
$ListingID = intval($_GET['ListingID']);
$AgentID = intval($_GET['AgentID']);

$q1 = mysql_query("SELECT * FROM re2_agents WHERE AgentID = ".$AgentID) or die(mysql_error());
$a1 = mysql_fetch_array($q1);

if(isset($_POST['s1']))
{
  $to = $a1['email'];
  $subject = $_POST['subject'];
  $message = $_POST['message'];
  $message .= 'Property:'."\n".$site_url.'/info.php?id='.$ListingID."\n\n";

  $headers .= 'Content-type: text/plain; charset=iso-8859-1'."\r\n";
  $headers .= 'Content-Transfer-Encoding: 8bit'."\r\n";
  $headers .= 'From: '.$_POST['u_name'].' <'.$_POST['u_email'].'>'."\r\n";

  if(!@mail($to, $subject, $message, $headers))
  {
    echo "error";
  }
  $thankyou = '<center><b><br><br><br>Thank you for your message!<br><br><a class=RedLink href="'.$site_url.'/info.php?id='.$ListingID.'">back to the property details</a></center>';

  require_once("templates/HeaderTemplate.php");
  require_once("templates/EmailThankyouTemplate.php");
  require_once("templates/FooterTemplate.php");
}

$AgentName = $a1['FirstName'].' '.$a1['LastName'];

/*
Here is where the error occured, in what I originally posted it 
was because I forgot that:

"empty() only checks variables as anything else will result in a 
parse error. In other words, the following will not work: 
empty(trim($name))."
*/
if(!empty($ListingID))
{
  $SubjectLine = "Property ID ".$ListingID;
}

require_once("templates/HeaderTemplate.php");
require_once("templates/EmailTemplate.php");
require_once("templates/FooterTemplate.php");

?>
 
0
•••
hi,

done excatly like you suggested but still no joy.

when i click send "error" comes up in the left side, though something strange happens.

a thank you message comes up and the form box aswell.

have a look

http://www.cheap-florida-holiday.com/email.php

also no emails are comming through.

what should i try?

cheers i am thankful for all suggestions!
 
0
•••
When I "sent" email via your form, there was no "listing_id" or "agent_id" in the querystring, so if there isn't then the variables that are defined by using "$_GET['listingID']" etc... won't be there, and therefore it cant search the database for that agent id because there isn't one there to search with.

There are two ways to check for this: both done in code below:

PHP:
<? 

require_once("conn.php"); 
require_once("includes.php"); 

//Move to vars, easier to work with. 
$ListingID = intval($_GET['ListingID']); 
$AgentID = intval($_GET['AgentID']); 

$q1 = mysql_query("SELECT * FROM re2_agents WHERE AgentID = ".$AgentID) or die(mysql_error());
//
// THIS IS THE FIRST ERROR CHECK
// IF AGENT ID IS EMPTY THERE WILL
// BE NO ROWS RETURNED
//
if(mysql_num_rows($q1)<1){
  echo "no rows returned...";
}
// --
$a1 = mysql_fetch_array($q1); 

if(isset($_POST['s1'])) 
{ 
  $to = $a1['email']; 
  //
  // SECOND WAY TO TEST...
  // SEE IF to VAR IS
  // EMPTY OR NOT
  //
  if(empty($to)){
    echo "no email address to send to...";
  }
  // --
  $subject = $_POST['subject']; 
  $message = $_POST['message']; 
  $message .= 'Property:'."\n".$site_url.'/info.php?id='.$ListingID."\n\n"; 

  $headers .= 'Content-type: text/plain; charset=iso-8859-1'."\r\n"; 
  $headers .= 'Content-Transfer-Encoding: 8bit'."\r\n"; 
  $headers .= 'From: '.$_POST['u_name'].' <'.$_POST['u_email'].'>'."\r\n"; 

  if(!@mail($to, $subject, $message, $headers)) 
  { 
    echo "error"; 
  } 
  $thankyou = '<center><b><br><br><br>Thank you for your message!<br><br><a class=RedLink href="'.$site_url.'/info.php?id='.$ListingID.'">back to the property details</a></center>'; 

  require_once("templates/HeaderTemplate.php"); 
  require_once("templates/EmailThankyouTemplate.php"); 
  require_once("templates/FooterTemplate.php"); 
} 

$AgentName = $a1['FirstName'].' '.$a1['LastName']; 

/* 
Here is where the error occured, in what I originally posted it  
was because I forgot that: 

"empty() only checks variables as anything else will result in a  
parse error. In other words, the following will not work:  
empty(trim($name))." 
*/ 
if(!empty($ListingID)) 
{ 
  $SubjectLine = "Property ID ".$ListingID; 
} 

require_once("templates/HeaderTemplate.php"); 
require_once("templates/EmailTemplate.php"); 
require_once("templates/FooterTemplate.php"); 

?>
see what that turns up
 
0
•••
hi,
it says

no rows returned...no email address to send to...error
 
0
•••
fried-chicken said:
hi,
it says

no rows returned...no email address to send to...error
Hmm... change
PHP:
//Move to vars, easier to work with.
$ListingID = intval($_GET['ListingID']);
$AgentID = intval($_GET['AgentID']);
to
PHP:
//Move to vars, easier to work with.
$ListingID = intval($_GET['ListingID']);
$AgentID = intval($_GET['AgentID']);

echo $ListingID . ' ' . $AgentID . '<br />';
and run it.. post what it says here.
 
0
•••
the problem is that it isn't getting anything from the database. This is because you aren't sending a listingid and a agentid to the script. Is there an agent in your database? if there is, in the html with the form in it so this:

<form method="post" action="emailscript.php?AgentID=#an agent id here that is in your database#&ListingID=#a listing id here that is in your database#">

that will send an agent Id and a listing Id to the script as well.
 
0
•••
thanks for everyone who tried to help me out.

just figured what the problem was.

the contact page can only be used by people who are signed in.

simple problem. i'll just put a formtomail cgi script on it.

thanks again for all the help.
 
0
•••
hmm.. ok - simple explination.

Hope it all works out for you.
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy โ€” Payment Flexibility
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back