3raser Posted July 12, 2010 Share Posted July 12, 2010 <?php //update views mysql_query("UPDATE amount SET views = views + 1"); //to $to = $_POST['to']; //from $from = $_POST['from']; //message $message = $_POST['message']; //subject $subject = $_POST['subject']; //this is so people can disallow emails to them $add_to_ignore = $_POST['ignore']; if($add_to_ignore) { //make sure the $add_to_ignore variable is safe $ignore_email = mysql_real_escape_string($add_to_ignore); //add it to the ignore list mysql_query("INSERT INTO ignored VALUES ('', '$ignore_email', '$ignore_email')"); echo "The email ". $add_to_ignore ." has been ignored. <a href='index.php'>Back</a>"; } elseif(!$message || !$to || !$message || !$subject) { echo "If you wish to block an email, which means no one can send a message from or to your email address, type in the email: <form action='index.php' method='POST'> <input type='text' maxlength='150' name='ignore'><input type='submit' value='Block'></form> <br><br><form action='index.php' method='POST'>Email from: <input type='text' name='from' maxlength='45'><br>Email to: <input type='text' name='to' maxlength='45'><br>Subject: <input type='text' name='subject' maxlength='60'> <br><br><textarea name='message' maxlength='1000' cols='50' rows='20'></textarea><br/><input type='submit'></form>"; } else { //banned words //filtered words $output = str_replace($bad_text, "****", $message); //spacing $output_final = str_replace("\n.", "\n..", $output); //code to check if email is on ignore list $check_ignored = mysql_query("SELECT COUNT(`id`) FROM `ignored` WHERE `to`='$to' OR `from`='$from'"); $check_it = mysql_fetch_array($check_ignored); //check if it is blocked or not if(!$check_it['COUNT(id)']) { //footer message $footer_message = "This message has been sent by <a href='http://emailpranker.netai.net/'>Email Pranker</a> - If you wish to add your email to the ignore/disallowed list, just click <a href='http://www.emailpranker.netai.net'>here</a>."; $output_final_final = $output_final."\r\r------------------------------------------\n".$footer_message; mail($to, $subject, $output_final_final, "From: ". $from .""); echo "The email has been sent to ". $to ."! <a href='index.php'>Back</a>"; //updated statistics mysql_query("UPDATE amount SET amount = amount + 1"); } else { echo "The owner of this email has put their email on the ignore list. We no longer allow emails to be sent to their address or sent from their address via our prank email service/website. <a href='index.php'>Back</a>"; } } ?> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/smudgefx/public_html/emailer/index.php on line 57 Why do I get this error?! Link to comment https://forums.phpfreaks.com/topic/207511-why-is-this-happening/ Share on other sites More sharing options...
robert_gsfame Posted July 12, 2010 Share Posted July 12, 2010 this part is the problem then $check_ignored = mysql_query("SELECT COUNT(`id`) FROM `ignored` WHERE `to`='$to' OR `from`='$from'"); try this $check_ignored = mysql_query("SELECT COUNT(id) FROM ignored WHERE to='$to' OR from='$from'"); Link to comment https://forums.phpfreaks.com/topic/207511-why-is-this-happening/#findComment-1084891 Share on other sites More sharing options...
Pikachu2000 Posted July 12, 2010 Share Posted July 12, 2010 Let's see just what happens when the query executes (or doesn't) . . . //code to check if email is on ignore list $query = "SELECT COUNT(`id`) FROM `ignored` WHERE `to`='$to' OR `from`='$from'"; $check_ignored = mysql_query( $query ) or die('Query string: ' . $query . '<br />Died with error: ' . mysql_error() . '<br />'); $check_it = mysql_fetch_array($check_ignored); Link to comment https://forums.phpfreaks.com/topic/207511-why-is-this-happening/#findComment-1084895 Share on other sites More sharing options...
Pikachu2000 Posted July 12, 2010 Share Posted July 12, 2010 this part is the problem then $check_ignored = mysql_query("SELECT COUNT(`id`) FROM `ignored` WHERE `to`='$to' OR `from`='$from'"); try this $check_ignored = mysql_query("SELECT COUNT(id) FROM ignored WHERE to='$to' OR from='$from'"); No, that isn't the problem. Backticks are necessary in this case. There are MySQL reserved words in the query string as field names. Link to comment https://forums.phpfreaks.com/topic/207511-why-is-this-happening/#findComment-1084896 Share on other sites More sharing options...
3raser Posted July 12, 2010 Author Share Posted July 12, 2010 FIXED I forgot to add the user to my database. (( Link to comment https://forums.phpfreaks.com/topic/207511-why-is-this-happening/#findComment-1084899 Share on other sites More sharing options...
Pikachu2000 Posted July 12, 2010 Share Posted July 12, 2010 Is this script called in as an include in another one? I'm not seeing any mysql_connect() or mysql_select_db(), (or an included file to do those) in this script. Nevermind, glad it's fixed . . . Link to comment https://forums.phpfreaks.com/topic/207511-why-is-this-happening/#findComment-1084906 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.