raimis100 Posted March 26, 2008 Share Posted March 26, 2008 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 More sharing options...
ansarka Posted March 26, 2008 Share Posted March 26, 2008 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 Link to comment https://forums.phpfreaks.com/topic/97962-help-me-fix-this-easy-script/#findComment-501201 Share on other sites More sharing options...
raimis100 Posted March 26, 2008 Author Share Posted March 26, 2008 Lol , it worked ; thnx Link to comment https://forums.phpfreaks.com/topic/97962-help-me-fix-this-easy-script/#findComment-501204 Share on other sites More sharing options...
marun Posted March 26, 2008 Share Posted March 26, 2008 <?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 ? */ ?> Link to comment https://forums.phpfreaks.com/topic/97962-help-me-fix-this-easy-script/#findComment-501207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.