3raser Posted July 12, 2010 Share Posted July 12, 2010 <?php //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 REMOVED FOR PHPFREAKS DUE TO BAD 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) { //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 list, just click <a href='#'>here</a>."; $output = $output.$message; mail($to, $subject, $output, "From: ". $from .""); echo "The message has been sent to ". $to ."!"; } 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 form. <a href='index.php'>Back</a>"; } } ?> Why do I receive the following error when I submit an email: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a5275546/public_html/index.php on line 61 And how do I make it so my <a href=''> link actually works in the email? The link works, but when you read the email it would be like this <a href=''>LINK</a>, so how do I do it? Link to comment https://forums.phpfreaks.com/topic/207492-2-errors/ Share on other sites More sharing options...
themistral Posted July 12, 2010 Share Posted July 12, 2010 Point 1 - I would guess that there is an error in your SQL. Try echoing the sql statement and run it through phpmyadmin to see if it runs ok. Point 2 - you will need to send it as an html email to get html tags to work. http://uk3.php.net/manual/en/function.mail.php Link to comment https://forums.phpfreaks.com/topic/207492-2-errors/#findComment-1084796 Share on other sites More sharing options...
3raser Posted July 12, 2010 Author Share Posted July 12, 2010 Thanks, HTML is working. But I couldn't find a solution to my SQL problem. I ran it into PhpMyAdmin, and kept giving me the same errors. Link to comment https://forums.phpfreaks.com/topic/207492-2-errors/#findComment-1084800 Share on other sites More sharing options...
xcoderx Posted July 12, 2010 Share Posted July 12, 2010 mebbe something with this line $check_it = mysql_fetch_array($check_ignored); and if(!$check_it) { you are fetching something in a array right? shound there not be somethin like $check_it['$check_ignored'];? im not sure just guessing Link to comment https://forums.phpfreaks.com/topic/207492-2-errors/#findComment-1084802 Share on other sites More sharing options...
3raser Posted July 12, 2010 Author Share Posted July 12, 2010 mebbe something with this line $check_it = mysql_fetch_array($check_ignored); and if(!$check_it) { you are fetching something in a array right? shound there not be somethin like $check_it['$check_ignored'];? im not sure just guessing I switched to that, but it still gives an error. Link to comment https://forums.phpfreaks.com/topic/207492-2-errors/#findComment-1084808 Share on other sites More sharing options...
Pikachu2000 Posted July 12, 2010 Share Posted July 12, 2010 Enclose your table and field names in backticks. "TO" and "FROM" are both MySQL syntax reserved words. $check_ignored = mysql_query("SELECT COUNT(`id`) FROM `ignored` WHERE `to`='$to' OR `from`='$from'"); Link to comment https://forums.phpfreaks.com/topic/207492-2-errors/#findComment-1084836 Share on other sites More sharing options...
3raser Posted July 12, 2010 Author Share Posted July 12, 2010 Enclose your table and field names in backticks. "TO" and "FROM" are both MySQL syntax reserved words. $check_ignored = mysql_query("SELECT COUNT(`id`) FROM `ignored` WHERE `to`='$to' OR `from`='$from'"); Thank you, it fixed the problem. Link to comment https://forums.phpfreaks.com/topic/207492-2-errors/#findComment-1084854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.