Resource id's

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
niallsc
Forum Newbie
Posts: 7
Joined: Thu Jun 10, 2010 1:09 pm

Resource id's

Post by niallsc »

Hello,
I will preface this question by saying that yes, I am a newb.... moving on though,
I am trying to open a google search webpage and get the source code, pretty simple i thought...
anyways every time I try it i get this weird "Resource id #6" or "Resource id #5"... Anyone know what might be causing this?
here is my source, any Help would be greatly appreciated!

Code: Select all

  $url="http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=";
	
  #$url= "http://search.yahoo.com/search;_ylt=Avxb5GJ0gxf5XZ4J4uOAM9CbvZx4?p=";
  $myWord1="used"; 
  $myWord2="cars";
  $newSearch=$url.$myWord1."+".$myWord2;
  
  #$searchSource=fopen("http://www.google.com/search?hl=en&q=used+cars&aq=f&aqi=g10&aql=&oq=&gs_rfai=", "r");	
  $searchSource= fopen($newSearch, "r");
  #$insideUrl= fgets($searchSource);
  
  
  #echo "<br>Url=";
  echo $newSearch;
  
  echo "\n";
  echo "$searchSource \n";


Thanks in advance :)
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Resource id's

Post by AbraCadaver »

Look up fopen() in the manual, it returns a file pointer resource. I would use file_get_contents().
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
niallsc
Forum Newbie
Posts: 7
Joined: Thu Jun 10, 2010 1:09 pm

Re: Resource id's

Post by niallsc »

You are amazing! file_get_contents did exactly what i needed! Thank you so much!
Post Reply