Jump to content

Help me fix this easy script


raimis100

Recommended Posts

I have just started to learn php so I need a little help

I cant fix this easy script;

 

[<?php

  $phrase = file_get_contents('http://www.google.com/search?hl=lv&q=loan+student&btnG=Mekl%C4%93t&meta=');
  $Poz1 = strpos($phrase, "height=25");
  echo ($Poz1);
  $Poz2 = strpos($phrase, "</a></h2><table");
  echo $Poz2;
  $Cip = &Poz2 - $Poz1;  /* can't I just use - ? */
  echo substr($phrase, $Poz1 , $Cip);     /* so whats wrong with these 2 lines ? */

?> 

 

Got it working with pascal but cant do the same with php

 

What im trying to do is get the title of the first result in google but it shows error Parse error: syntax error, unexpected '-', expecting T_PAAMAYIM_NEKUDOTAYIM

 

(edited by kenrbnsn to add


tags)

Link to comment
https://forums.phpfreaks.com/topic/97962-help-me-fix-this-easy-script/
Share on other sites

try this

<?php

  $phrase = file_get_contents('http://www.google.com/search?hl=lv&q=loan+student&btnG=Mekl%C4%93t&meta=');
  $Poz1 = strpos($phrase, "height=25");
  echo ($Poz1);
  $Poz2 = strpos($phrase, "[/url]</h2><table");
  echo $Poz2;
  $Cip = $Poz2 - $Poz1;  /* can't I just use - ? */
  echo substr($phrase, $Poz1 , $Cip);     /* so whats wrong with these 2 lines ? */

?> 

 

i am getting result for above

<?php

  $phrase = file_get_contents('http://www.google.com/search?hl=lv&q=loan+student&btnG=Mekl%C4%93t&meta=');
  $Poz1 = strpos($phrase, "height=25");
  echo ($Poz1);
  $Poz2 = strpos($phrase, "[/url]</h2><table");
  echo $Poz2;
  $Cip = &Poz2 - $Poz1;  /* can't I just use - ? */
---------^ you have & and should be $
  echo substr($phrase, $Poz1 , $Cip);     /* so whats wrong with these 2 lines ? */

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.