Jump to content

TheEvilMonkeyMan

Members
  • Posts

    33
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.purplekiwi.net/

Profile Information

  • Gender
    Not Telling

TheEvilMonkeyMan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Jay, you da man. That seems to be working for all my links. Thanks
  2. The \b made it cut the URL off after the .com leaving out the /file.htm etc and not too much luck with the \s|$ - not sure why. And there's still a strange thing happening where a random <a will show up, breaking my website layout. :-\
  3. Hi, I have a function using preg_replace_callback to go through a string replacing all instances of URLs with a link to that URL. It works, but not when the link is at the end of the string, since it uses white space to mark the end of the URL. I'm sure it can't be that hard. Could somebody help me out? function trim_urls_callback($matches) { $temp = substr($matches[0], 0, 15); $final = "<a href=\"$matches[0]\" title=\"$matches[0]\">$temp…</a> "; return $final; } function trim_urls($string) { $string = preg_replace_callback('/(ht|f)tps?:\/\/[A-Za-z0-9_.-]{3,}\/?\s/', 'trim_urls_callback', $string); return $string; }
  4. Yeah, it's probably the bug in PHP 5.3.0 that caused PHP to crash when you mysql_close() when there's no handle given.
  5. Are you sure the connection is open when you close it? See if adding a conditional statement helps your server crashing problem if($conn) { mysql_close($conn); } Otherwise you might want to try reinstalling Apache and/or MySQL.
  6. Ah, I fixed it! Thanks for your reply SELECT q.*, ans.content AS answer FROM questions_map_domains AS map, questions_new AS q LEFT JOIN answers AS ans ON (ans.question_id = q.id) WHERE q.id = map.question_id AND map.domain_id = $domain_id AND q.down_votes < 3 ORDER BY q.up_votes DESC, q.down_votes ASC LIMIT 10
  7. Hey, I'm having trouble with this query that's supposed to left join an 'answer' row to a 'question' row but I keep getting "Unknown column q.id in 'on clause'". Here's the query: SELECT * FROM questions_new AS q, questions_map_domains AS map LEFT JOIN answers AS ans ON (ans.question_id = q.id) WHERE q.id = map.question_id AND map.domain_id = $domain_id
  8. Ah, that makes sense now Thanks Pikachu2000 and gizmola for your thorough answers.
  9. Oh, I was only echoing it to see the output... I would have thought mysql_real_escape_string is okay except that it let "SELECT * FROM users" and just about any other SQL through. I could effectively DROP tables that way, yeah?
  10. Just some simple input cleaning example/s would be great... need to make sure they don't abuse my mysql_query() with their submitted post...
  11. if(isset($_POST['submit_post'])) { if(isset($_POST['post_content']) && !empty($_POST['post_content'])) { if(get_magic_quotes_gpc()) { $content = stripslashes($_POST['post_content']); } else { $content = $_POST['post_content']; } $content = strip_tags($content); $bb_from = array( '/\[b\](.*?)\[\/b\]/', '/\[i\](.*?)\[\/i\]/', '/\[u\](.*?)\[\/u\]/' ); $bb_to = array( '<b>$1</b>', '<i>$1</i>', '<u>$1</u>' ); $content = preg_replace($bb_from, $bb_to, $content); $content = mysql_real_escape_string($content); echo stripslashes($content); } }
  12. I thought I'd done this a hundred times before... but I am lost. Even after running mysql_real_escape_string, strip_tags and addslashes etc, I can still enter SQL into my input and it screws with the query. I can't simply use regex to check for valid characters since it's an input that lets the user format a post with BBcode and characters they want. What's the proper way to 'clean' the input, then? Thanks in advance
  13. Thanks for your replies. I obviously haven't thought this through enough and will take another look at what I'm trying to achieve.
  14. No it's not... process_registration.php line 69: mysql_query("(INSERT INTO $table (access, username, password, day, month, email, cash, S_name, g_chance, m_chance, luck) VALUES ('0','$username','$password','$day','$month','$email','2000','$s_name',','1','1','50'))"); You need to add VALUES or it's an invalid query and you will get an SQL error.
×
×
  • 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.