Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. ??? Easier to just write your own. You will spend more time trying to integrate a 3rd party script into your project.
  2. This error is generated due to the variable $rowAccount not having a data type. Probably due to your sql query not returning a result. Also you are surpressing errors using @ You should get your query to die or have an error routine setup upon errors. i.e. if(!$result = mysql_query($query)) { die(mysql_error()); } You can disable notices by changing the error_reporting parameter in your php.ini file i.e error_reporting = E_ALL & ~E_NOTICE Shows all errors except notices
  3. If it's just text yes, not if HTML and the entities exist already
  4. By storing the HTML entity you are guaranteed that the output will be correct. There are some mbstring functions that allow you to check encoding. http://uk.php.net/manual/en/function.mb-check-encoding.php
  5. The code above only goes as far as giving you an array of the occurances of each word in the text. I left it up to you to complete the rest. Where are you upto?
  6. Yes; using the mail() function to send attachments. That's wrong in itself. Use the following package: http://pear.php.net/package/Mail_Mime
  7. Remeber if you change variable names, change in subsequent functions $cloud_one_words=explode(' ',$cloud_one); $cloud_two=count($cloud_one); to $cloud_one_words=explode(' ',$cloud_one); $cloud_two=count($cloud_one_words); Also check your conditional braces! I have rewritten this for you and tested. I have used cleaner functions for condition testing. You may also want to think about loading the stop words in from a text file making it easier to add to <?php if(isset($_POST['submitted'])) { if(!strlen(trim($_POST['text']))) { print "<span style='color:red;font-weight:bold;'>Please enter some text!!</span><p/>"; include('form.php'); } else { // format text $cloud_one_text = $_POST['text']; $cloud_one_text = strtolower(stripslashes($cloud_one_text)); $cloud_one_text = ereg_replace('[^a-zA-Z ]+', '', $cloud_one_text); // remove stopwords $stopwords = array("a", "about", "above", "above", "across", "after", "afterwards", "again", "against", "all", "almost", "alone", "along", "already", "also","although","always","am","among", "amongst", "amoungst", "amount", "an", "and", "another", "any","anyhow","anyone","anything","anyway", "anywhere", "are", "around", "as", "at", "back","be","became", "because","become","becomes", "becoming", "been", "before", "beforehand", "behind", "being", "below", "beside", "besides", "between", "beyond", "bill", "both", "bottom","but", "by", "call", "can", "cannot", "cant", "co", "con", "could", "couldnt", "cry", "de", "describe", "detail", "do", "done", "down", "due", "during", "each", "eg", "eight", "either", "eleven","else", "elsewhere", "empty", "enough", "etc", "even", "ever", "every", "everyone", "everything", "everywhere", "except", "few", "fifteen", "fify", "fill", "find", "fire", "first", "five", "for", "former", "formerly", "forty", "found", "four", "from", "front", "full", "further", "get", "give", "go","had", "has", "hasnt", "have", "he", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "him", "himself", "his", "how", "however", "hundred", "ie", "if", "in", "inc", "indeed", "interest", "into", "is", "it", "its", "itself", "keep", "last", "latter", "latterly", "least", "less", "ltd", "made", "many", "may", "me", "meanwhile", "might", "mill", "mine", "more", "moreover", "most", "mostly", "move", "much", "must", "my", "myself", "name", "namely", "neither", "never", "nevertheless", "next", "nine", "no", "nobody", "none", "noone", "nor", "not", "nothing", "now", "nowhere", "of", "off", "often", "on", "once", "one", "only", "onto", "or", "other", "others", "otherwise", "our", "ours", "ourselves", "out", "over", "own","part", "per", "perhaps", "please", "put", "rather", "re", "same", "see", "seem", "seemed", "seeming", "seems", "serious", "several", "she", "should", "show", "side", "since", "sincere", "six", "sixty", "so", "some", "somehow", "someone", "something", "sometime", "sometimes", "somewhere", "still", "such", "system", "take", "ten", "than", "that", "the", "their", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "thereupon", "these", "they", "thickv", "thin", "third", "this", "those", "though", "three", "through", "throughout", "thru", "thus", "to", "together", "too", "top", "toward", "towards", "twelve", "twenty", "two", "un", "under", "until", "up", "upon", "us", "very", "via", "was", "we", "well", "were", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "who", "whoever", "whole", "whom", "whose", "why", "will", "with", "within", "without", "would", "yet", "you", "your", "yours", "yourself", "yourselves", "the"); $cloud_one_text = preg_replace('/\b('.implode("|",$stopwords).')\b/i', '', $cloud_one_text); // extract words $cloud_one_words = explode(' ',$cloud_one_text); $cloud_one_word_count = count($cloud_one_words); if($cloud_one_word_count < 100) { print"<span style='color:red;font-weight:bold;'> You must enter atleast 100 words!</span><p/>"; include('form.php'); } else { print "Thanks for entering the required amount of words"; // remove empty words foreach($cloud_one_words as $key => $word) { if(!strlen($word)) { unset($cloud_one_words[$key]); } } $cloud_one_word_occurances = array_count_values($cloud_one_words); print "<pre>"; print_r($cloud_one_word_occurances); print "</pre>"; exit(); } } } else { include('form.php'); } ?>
  8. Firstly your function str_replace() is incorrect as it does not accept regex patterns. Check my post above. $cloud_one =str_replace('[^a-zA-Z ]+', '', $cloud_one); Should be $cloud_one = ereg_replace('[^a-zA-Z ]+', '', $cloud_one); Also you will have to get used to not keep using the same variable name where you may need to reuse the results of a previous function on that variable // explode all words into an array $cloud_one_words = explode(' ',$cloud_one); // create an array of word occurances $count_words = array_count_values($cloud_one_words); Also try to make your variable names have something to do with what the variable contains rather than just $cloud_one this makes it easier to follow. i.e. text: $cloud_one_text, words: $cloud_one_words, number of words: $cloud_one_word_count, word occurances: $cloud_one_word_occurances
  9. Thats because you are storing the word count in the $cloud_one variable when that should be the array of words. Use another variable $cloud_one = explode(' ',$cloud_one); $cloud_one_word_count = count($cloud_one); if($cloud_one_word_count < 100) { }
  10. <?php $numberofwords = count(explode(" ",$text)); if($numberofwords < 100) { print "You must enter at least 100 words"; } else { } ?>
  11. The first thing is removing the punctuation. You could be forever adding new lines to str_replace for punctuation. You are better removing everything that is not alphabetic in one fowl swoop. Also heres how to count word occurances better <?php $text = "This is a sample sentence. It's a fine day. He said, 'this sample looks fantastic'."; // change to lowercase $text = strtolower($text); // remove punctuation $text = ereg_replace('[^a-zA-Z ]+', '', $text); // remove stop words $stopWords = array('a', 'is', 'he'); $text = preg_replace('/\b('.implode("|",$stopWords).')\b/i', '', $text); // remove any blank spaces $words = explode(" ", $text); foreach($words as $key => $word) { if(!strlen($word)) { unset($words[$key]); } } // count occurances $wordCount = array_count_values($words); print "<pre>"; print_r($wordCount); print "</pre>"; ?>
  12. In the email client have you checked the message headers? Are they correct as you have set in the program. Correct From / To
  13. No, its just your headers. You certainly do not need this: ini_set ( "sendmail_from", "root@joeblogs.com" ); Here: <?php $name = "Joe Bloggs"; $from = "info@joebloggs.com"; $to = "sales@joebloggs.com"; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain;\r\n"; $headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: php\n"; $headers .= "From: \"".$name."\" <".$from.">\n"; $headers .= "Reply-To: \"".$name."\" <".$from.">\n"; $subject = "Test Message"; $mail = "This is the email body\n"; mail($to, $subject, $mail, $headers, "-f".$from); ?>
  14. There are issues with your code Dathremar. 1. The trim function is being used on a variable that has already been trimmed 2. There is no need to use an else statement after an exit function. The script will terminate if the condition is not met. Thirdly you code should check for a valid email address not just if the field is empty. <?php // get posted data into local variables $mail = trim($_POST['mail']); if(!eregi("^[^@]{1,64}@[^@]{1,255}$", $mail)) { exit("Please enter a valid E-Mail address."); } echo "The E-Mail You Entered Is ".$mail; ?>
  15. WHERE language !='arabic'
  16. <?php $d = dir("/path/to/dir/"); while($contents = $d->read()) { if($contents != "." && $contents != "..") { unlink($contents); } } $d->close(); ?>
  17. Are they hotmail addresses?
  18. Not really and using tables is not always the best option. Do you understand CSS? If so you can set all the layout, sizes, etc within the stylesheet. All you need to loop is i.e foreach() { print "<div id='container'></div>"; } Our designers make all kinds of layouts like this and I just embed them in loop. For instance the above container may start on a new line after every 4 containers. Its all done with CSS.
  19. Use imagemagick for image manipulation. Far better than any method using the GD library. http://www.imagemagick.org/script/index.php
  20. Why are you even using sessions for a registration form?
  21. Do you realize you have just posted the algorithm to your captcha aswell as the url $RandomStr = md5(microtime()); $ResultStr = substr($RandomStr,0,5); You better change this before it goes live i.e. $RandomStr = md5(microtime()."This is a secret string"); $ResultStr = substr($RandomStr,0,5);
  22. Output buffering http://uk3.php.net/manual/en/function.flush.php
  23. Oh, its nothing fancy - I mentioned it above
  24. You only learn from your mistakes
  25. Thanks, used an alternate solution
×
×
  • 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.