this is the line that gives me troubles :
print $uri=$searchresults[resultElements][$i][URL].'<br>';
the error is the following: Fatal error: Cannot use string offset as an array
Now I don't understand sometimes I get no results only the error, sometimes 2 results and the error and so on. I don't think I can understand this...
I want to build a friendly api search with at least 5 result pages from google, but this error stops me...
B4 I tryed 20 and worked now it gives me the creeps...
If someone knows how to deal with this problem please help
I reply to myself now. I mean this is strange.
I changed print to echo the script works well, no fatal error, I changed back to print and still works well. I had this error manny times and it gives me a headache...
Is it a php bug ? Or something that is not working well ?
Never encountered that one before, but it seems like it only affects arrays that are three levels deep (http://bugs.php.net/bug.php?id=28107) and may or may not be a bug.
Also, I'm assuming resultElements and URL are constants? Make sure they are assigned the proper values.
Try rewriting the code in a different way and see if that helps.
Neah That won't work, false it's 0, true is 1 and you can't put $res in simple quote because it won't work, maybe in double quotes, so you can't put everything between simple quotes...
Once again I must say that I don't know why this error keeps geting, at first it worked fine, after I modified some values, the error camed...
Anybody knows how deal with it, a code rewrite or something..
I tried different ways, it worked but after that the same error came up.
I hate this error...
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
I modified the value of $a
in the for loop
for($a=0;$a<5;$a++)
I put here 10 and 6 and 7
when I modified this value the error camed:
I could see 20 links and then fatal error...
I know it works because it worked the first time...
Maybe I sould do a xml request that would work much better (I think)
The thing is that I build this code and as a writer of it: It's buggy and it drives me crazy, it should work like a daydream.
About $uri Neah $uri has nothing to do with it.
I did an echo $searchresults[resultElements][$i][URL].'<br>'; b4 and it did the same, until now the code has suffered lots of modification, I mean I posted only the loop. I will come with the function