I've been playing with a couple of php scripts that query Google and one of them works fine written as follows: $data=file_get_contents("http://www.google.com/search?hl=en&q=allintitle:".$s."&btnG=Google+Search"); Code (markup): That creates a call to Google emulating a Google search for allintitle:keyword The problem arises when I wish instead to implement intitle:"keyword" searches, as in this instance I need the double quotes wraped around the keywords to be included. I tried adding another set of double quotes, as shown below, which not surprisingly didn't work, but then nor did escaping them with \ nor changing either set of quotes from single to double or using their ASCI quivalents (apparenlty PHP uses ANSI if that helps). $data=file_get_contents("http://www.google.com/search?hl=en&q=allintitle:"".$s.""&btnG=Google+Search"); Code (markup): I'm sure that I'm missing something obvious, but I can't think what. Please help!
try this $data=file_get_contents('http://www.google.com/search?hl=en&q=allintitle:"'.$s.'"&btnG=Google+Search'); PHP:
Also you can use a backslash to escape it, Like this: $data=file_get_contents("http://www.google.com/search?hl=en&q=allintitle:\"".$s."\"&btnG=Google+Search"); Code (markup):
Sorry, as discussed, doesn't work. Here's the error message: Parse error: syntax error, unexpected '"' in /usr/local/psa/home/vhosts/marketappeal.co.uk/httpdocs/google-multiple-count-scraper-table-3.php on line 101 Code (markup):
Sorry, but as discussed, this also doesn't appear to work... Error message: Parse error: syntax error, unexpected '"' in /usr/local/psa/home/vhosts/marketappeal.co.uk/httpdocs/google-multiple-count-scraper-table-3.php on line 101 Code (markup):
Sorry but the code posted above by me should work in %100 As the error message says, check what you have at line 101 in google-multiple-count-scraper-table-3.php
Hi , Here is the solution $data=file_get_contents("http://www.google.com/search?hl=en&q=allintitle:\".$s.\"&btnG=Google+Search"); Thanks
Same as the last suggestion. Still doesn't work, despite being the "official" solution. I don't know why. Any guesses.
Sorry seo alchemist, But it seems all these methods work. You must have a problem elsewhere. <?php $s = "Testing..."; $jezz="http://www.google.com/search?hl=en&q=allintitle:\"".$s."\"&btnG=Google+Search"; $pluswebdev = 'http://www.google.com/search?hl=en&q=allintitle:"'.$s.'"&btnG=Google+Search'; $nicewallpapers = "http://www.google.com/search?hl=en&q=allintitle:\".$s.\"&btnG=Google+Search"; $nicewallpapers2 = "http://www.google.com/search?hl=en&q=allintitle:\"$s\"&btnG=Google+Search"; print "<table border=\"1\"><tr><td>Jezz's way :</td><td>".$jezz.'</td><br /></tr>'; print "<tr><td>pluswebdevs's way :</td><td>".$pluswebdev.'</td><br /></tr>'; print "<tr><td>nice wallpapers's way :</td><td>".$nicewallpapers.'</td><br /></tr>'; print "<tr><td>nice wallpapers's way (fixed) :</td><td>".$nicewallpapers2.'</td><br /></tr>'; print "</table>"; ?> Code (markup): Copy this code to a blank file, and see for yourself
Thank you everyone for your solutions. It turns out that the problem was that sometimes I was adding one of the escaped " inside the original pair rather than outside them, meaning that the \" was being wrongly interpreted as part of the html rather than as an element of the php. Rep points added to everyone who offered help.