Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. 1.) Are you sure they're being set in the first place? 2.) I assume you have session_start() at the top of the second page?
  2. I find it makes the text look very disjointed. Since the new line doesn't come at the edge of the screen, it makes it look like it was done for a particular reason, e.g. a new paragraph.
  3. That's a new function for me and it would no doubt be quicker, since it doesn't use regex. On the otherhand, i think it's safer to have a whitelist of characters than a blacklist - it would be very easy to forget some of the characters you wanted to disallow.
  4. Your problem is that you never define $this->Where On a different note, it's generally bad practice to give your php scripts the extention .inc Unless you set up your webserver to parse .inc files as .php files, someone could browse directly to the page and view the PHP source code. And even if you do, you could change hosts and forget about this, which could create a security issue down the line.
  5. Using linux? Read up about cronjobs. Using windows? Read up about scheduled tasks.
  6. That idiot may be me, you or alot others. If i cant write code efficiently, it means im an idiot? Anyone instead of any idiot could have been alot more appropriate. Calm down. AP81's sentence doesn't actually imply that if you can't code efficiently then you are an idiot.
  7. I think you misunderstood - preg_match does an different thing to mysql_real_escape_string. By using the preg_match(), you're restricting which characters can be part of the string. By using mysql_real_escape_string(), you're escaping all dangerous characters before they go near the database. You should look to use mysql_real_escape_string() on all strings being stored in the database. For a login system, i would use preg_match() to check the username, but not the password. Why should you prevent someone using special characters in their password? You want to be using it on the username, because you dont want people having stupid things quote html tags in their names. As for the comment regarding your regex, you should make sure to include the ^ and $ to signify the start of the string. You want your pattern to be the entire string, not just part of it. To explain, say you had the pattern: "/[a-zA-Z]+/" This would match and string with at least one letter in it. That means that someone could place dangerous characters in their username, so long as it still had a letter in. However, the pattern: "/^[a-zA-Z]+$/" Would only allow a string which only contained letters.
  8. Can't you just return two rows, one of which contains the number of errors and one of which contains the number of warnings? SELECT page.id,type,COUNT(error.type) as count FROM page,error WHERE page.id=1 GROUP BY error.type
  9. So you want someone to do this for you? You'd be better off posting in the freelance section.
  10. Maybe its just me, but i find it makes it really hard on the eye...
  11. You might want to check that your host supports PHP's mail function. I know that a quite a few free hosts disabled this function to prevent people creating sites to send spam easily.
  12. Put parenthesis around the OR part: <?php $qryProcessor = mysql_query("SELECT p.products_id, p.products_model, p.products_price, pd.products_name FROM products p, products_description pd WHERE p.products_id = pd.products_id AND pd.language_id = 1 AND (p.products_model LIKE 'DVD-DH%' OR p.products_model LIKE 'DVD-FD%') GROUP BY p.products_id ORDER BY p.products_price") or die(mysql_error()); ?>
  13. Try: td><div align="left"><?php echo nl2br($row_keywords['Ticket']); ?> Can you use tags around your code when you post please? Makes it much easier to read.
  14. Looks like you need the mysqli_connect_error() function rather than mysqli_error(). Try that and see what it says.
  15. Well if you already have some javascript/ajax to help you trim an image, it should just be a case of getting that image with PHP first.
  16. You dont use it on your form. I assume your form continues and you have a textarea somewhere? And this is the field you're having trouble with? You use it when you output the data, that is, after it has been submitted and stored in the database.
  17. Not entirely sure why you'd have a need to store all those different types in one column, but regular expressions are you friend: $sql = "SELECT * FROM tbl WHERE field REGEXP '^[0-9.]+$'
  18. Echo the error that mysql gives: mysqli_select_db("meetingsEventLocation") or die("Unable to select database<br />".mysqli_error());
  19. 1.) there's no need to enter and exit out of PHP like that. 2.) You're not echoing the variables. Try: <?php while ($row = mysql_fetch_array($result)) { echo '<td>'.$row['lname'].' '.$row['fname'].' '.$row['mname'].'</td>'; } ?> When you post, can you place all your code in the tags please? It makes it much easier to read.
  20. You use it when you echo out the post. If, for exampe, you have a loop echoing out the forum posts and the variable is called $post, you'd just do: echo nl2br($post); Without any of your code, i can't really help you beyond that.
  21. Just use the nl2br() function. Thats what it's for. Not entirely sure where all this talk of < pre> tags has come from. Use it on the output from the database, not before you store it in the database.
  22. Hmm, not sure if thats quite possible. You could do something like: 1.) User chooses what webpage they want a screenshot of. 2.) Use PHP to create the screenshot of the whole page with the above function 3.) Output the whole screenshot 4.) Use javascript to select an area of the image 5.) Have PHP trim the image based on that selection
  23. You'd have to go into regular expressions. Im sure it would be much more efficient to do this with the split, otherwise you'd have the regex overhead on every single comparison. I don't think that could be easily incorporated into the above. So try: <?php $dictionary = array('this','is','a','test','dictionary'); $sentence = 'This? is a "test" sentence'; $words = preg_split('/(\.|\?|!| |,|;|:|&|\'|")/',$sentence,-1,PREG_SPLIT_NO_EMPTY);//if you need to add other punctuation, separate it with a pipe(|). If its a special character, you'll need to stick a backslash before it. foreach($words as $k => $v){ $words[$k] = strtolower($v); } $errors = array_diff($words,$dictionary); foreach($errors as $v){ $sentence = str_ireplace( $v ,'<font color="blue"><b>'.$v.'</b></font>',$sentence); } echo $sentence; ?>
×
×
  • 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.