Jump to content

TheEvilMonkeyMan

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by TheEvilMonkeyMan

  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.
  15. INSERT INTO users VALUES (access, username, password, day, month, email, [...]
  16. You're better off using the proper move_uploaded_file() function for this. $upload_dir = './images/'; move_uploaded_file($_FILES['image']['tmp_name'], $upload_dir . $imagename);
  17. I was thinking of the setcookie function in Javascript. The PHP setcookie() function relies on HTTP headers which are returned for any kind of GET request (ie. even Javascript files). So there won't be any kind of problem calling setcookie() before outputting your Javascript so long as you call it before printing any output. Hope this answers your question.
  18. Inside your loop where you print out all the <option>s, check if $car is equal to $_GET['car'] and, if so, print out selected="selected" in your tag otherwise print it out without. if($car == $_GET['car']) { echo "<option value=\"$car\" selected=\"selected\">$car</option>"; } else { echo "<option value=\"$car\">$car</option>"; }
  19. The setcookie function sets the cookie on the client side after the page has loaded, so you don't need to worry about headers etc
  20. print_r() has a second parameter called 'return' and it's a true/false of whether it will print the output or return it. Here's an example taken from the PHP manual page for print_r() <?php $b = array ('m' => 'monkey', 'foo' => 'bar', 'x' => array ('x', 'y', 'z')); $results = print_r($b, true); // $results now contains output from print_r ?>
  21. Can you please post the error here?
×
×
  • 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.