Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

PHP has methods for URL parsing. There's no need to approximate them with regexes:

  $query_string = parse_url($_SERVER["HTTP_REFERER"], PHP_URL_QUERY);
  parse_str($query_string, $vars);
  $term = $vars['q'];
  $rank = $vars['cd'];
  $url = $vars['url'];
Correct code is even shorter.


That's awesome! Definitely gonna update the post with your code.


And please, please fix the SQL code. It isn't helping noobs (it's not even valid SQL), and it's an eye-sore for people who know how to insert 3 variables into the DB.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: