Jump to content

PHP E-mailing HELP please!


PHPnewby!

Recommended Posts

Hi guys, I am trying to allow all members of my website who have provided certain information to be listed and a link to "e-mail this member" encorporated. I am getting the error message:

 

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /export2/webroot/users/c3031698/ContactMembers.php on line 138 ???

 

Any ideas? It was displaying the information correctly before, but the e-mail address was not being carried to the e-mail for sending. Also, is mailto really old fashioned? Is it better to carry the variables to a form? If so, how? Thanks....code below!

 

<?php echo "Your Username: ".$User;

 

$query="SELECT * FROM Members WHERE DOB!='NULL' AND Gender!='NULL'";

$result=mysql_query($query);

 

$num=mysql_numrows($result);

 

echo "<b><center>Member Details</center></b><br><br>";

 

$i=0;

while ($i < $num) {

 

$Username=mysql_result($result,$i,"Username");

$Emailaddress=mysql_result($result,$i,"Emailaddress");

$Moto=mysql_result($result,$i,"Moto");

$DOB=mysql_result($result,$i,"DOB");

$Gender=mysql_result($result,$i,"Gender");

$Interests=mysql_result($result,$i,"Interests");

$DestinationsVisited=mysql_result($result,$i,"DestinationsVisited");

$Message=mysql_result($result,$i,"Message");

 

echo "<b>Username: $Username </b><br><b><a href=mailto: $Emailaddress>E-mail This Member</a></b><br>Motto: $Moto<br>Year of Birth: $DOB<br>Gender: $Gender<br>Interests: $Interests<br>Destinations Visited: $DestinationsVisited<br>Message to other members: $Message<br><hr><br>";

 

$i++;

}

 

//code obtained and adapted from: http://www.freewebmasterhelp.com/tutorials/phpmysql/4

?>

?>

Link to comment
https://forums.phpfreaks.com/topic/38003-php-e-mailing-help-please/
Share on other sites

For starters, the function is mysql_num_rows() not mysql_numrows(). Secondly, you must always check to see if your query was successfull before trying to use any result. The basic syntax is....

 

<?php
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      // $result is safe to use.
    } else {
      // no records found.
  } else {
    // query failed.
  }
?>

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.