for($i=0;$i<=9;$i++)
{
$resul=$ggl[$i][URL];
echo $resul.'<br>';
$fpw=fwrite($fp, $resul."\n");
flush(); //results real time
}
//echo '<br><br>';
$res+=10;
}
$fpc=fclose($fp);
}
Now this worked like a charm when I did the results backwords.
But When I modified the value of $a, for example I put there 10;
I saw some results let's say like 5 I realy don't remember and then bam the error:
Fatal error: Cannot use string offset as an array
the line indicating the error was this one:
$resul=$ggl[$i][URL];
Once again I telled to myself, "what the hell is going on ?"
so you see the code builded in a different way
My guess is that the $i variable exceeds the number of array elements. The times it works, there are enough elements. The times it has an error, there are not enough. You would hope that there would have been an "index out of range" message, but the message you are getting is related to the index value/type...
__________________
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???
My guess is that the $i variable exceeds the number of array elements. The times it works, there are enough elements. The times it has an error, there are not enough. You would hope that there would have been an "index out of range" message, but the message you are getting is related to the index value/type...
You say that but every result has 10 links maxim
so from 0 to 9 it's okay there is no exeeding and if it's not there then the output is empty or better said no result, what do you expect me to believe ?
I think I need to rewrite the code... If somebody has any Ideea how to remake this code please post, also try this function on your server and tell me what happens.
Even though you request a maximum of 10 results, there is no guarantee you will get 10 each and every time.
I recommend replacing the For loop with a foreach loop -
PHP Code:
foreach($searchresults['resultElements'] as $result) {
// code here to output the results
}
This will only process as many elements as there are.
__________________
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???
Even though you request a maximum of 10 results, there is no guarantee you will get 10 each and every time.
I recommend replacing the For loop with a foreach loop -
PHP Code:
foreach($searchresults['resultElements'] as $result) {
// code here to output the results
}
This will only process as many elements as there are.
I put the script to a online server. It works with no problems
any key that I insert works like a charm. You should test it yourself and see.
I hope not to see the error again...
Also do you know how to install simplexml ? Because I want to install it on my online server
On my localhost I have php 5.1.4 and apache 2.2.2 and simplexml is installed by default. On my server is not installed
Also do you know how to install simplexml ? Because I want to install it on my online server
On my localhost I have php 5.1.4 and apache 2.2.2 and simplexml is installed by default. On my server is not installed
__________________
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???