Hello, For some reason, in one of my php scripts my get search query command is not working. Here it is: $searchquery = ($_GET['query']); // connect to a URL if (!$wsql->connect('url', '$searchquery')){ print 'Error while connecting: ' . $wsql->error; exit; The search query is taken from the url on passed on from the previous page. (The search query in this case is an url. I'm using ?query= to pass through an url.) The script is reading it as $searchquery instead of the url. Could you please tell me what could possibily be stopping this from working? Thanks
Your problem is that you don't need the single quotes around $searchquery... wsql->connect('url', $searchquery) will work fine
Thank you very much for you help! EccentricNick, your advice was right, it's working now. I hope to be able to return the help one day.
I have another question, which I think you'll be able to answer. How do I take information out of specific points in an url? For example, in this url, which will be in the browser: http://news.search.yahoo.com/news/rss%3fei%3dUTF-8%26p%3dlarge%2bcrocodiles%26eo%3dUTF-8&TEMPLATE=newsitemtemplate.html&GUID=http://us.rd.yahoo.com/dailynews/rss/search/large%2bcrocodiles/SIG%3d11qv3b00d/*http%253A//news.yahoo.com/s/kmbc/20070717/lo_kmbc/13693092 Code (markup): I want to take the part that follows the *, and display it in a link on the new page.
$url = 'http://news.search.yahoo.com/news/rss%3fei%3dUTF-8%26p%3dlarge%2bcrocodiles%26eo%3dUTF-8&TEMPLATE=newsitemtemplate.html&GUID=http://us.rd.yahoo.com/dailynews/rss/search/large%2bcrocodiles/SIG%3d11qv3b00d/*http%253A//news.yahoo.com/s/kmbc/20070717/lo_kmbc/13693092'; $new_url = rawurldecode(rawurldecode(end(explode('*', $url)))); echo $new_url; PHP: Seems like the URL has been URL encoded twice. That's why I'm applying the function twice to decode it.
Thanks a lot Nico. Could I replace * with a different to extract from a different starting point in the url? Was it necessary to decode the url, seeing that the part I wanted was not encoded? Thanks
For example: http://news.google.com/news/url?sa=T&ct=us/4-0&fd=R&url=http://www.theregister.co.uk/2007/07/17/google_itvcon_keynote/&cid=0&ei=jUGdRtXqO4T20AHt3KiJAQ Code (markup): Do I replace * with url= ?
Hello, I have now written the following code: $url = ($_GET['url']); $new_url = rawurldecode(rawurldecode(end(explode('*', $url)))); // connect to a URL if (!$wsql->connect('url', $new_url)){ $url = ($_GET['query']); $new_url = rawurldecode(rawurldecode(end(explode('*', $url)))); } if (!$wsql->connect('url', $new_url)){ print 'Error while connecting: ' . $wsql->error; exit; } PHP: I'm hoping that if the script cannot extract the url from the complete url, then it will try to extract it from the query. Unfortunately, if it cannot extract it from the url, it stops. It doesn't try to get it from the query. What am I doing wrong? (In case it seems strange that I'm doing this: $url = ($_GET['url']); works for Google feeds, but doesn't for Yahoo feeds; $url = ($_GET['query']); works for Yahoo, but not Google. So, I need the script to try both before stopping.) Please help me with this. Thanks. Luke