Thread: help with code
View Single Post
Old 02-04-2008, 07:19 AM   #1 (permalink)
sarmenhb
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default help with code

im trying to use file() to grab the source code of a webpage and position the pointer to where the keywords are displayed and print them to the screen. but i keep getting errors, can you see why?

i thank thee from the deepest

Code:
<?php
if(isset($_POST['submit'])) { 

$code = $_POST['url'];
$source = file($code);

foreach ($source as $line_num => $output) {
//for each key as value  key is hidden , value is line number looking in $source
    
	$str = $output;
	$start = strpos($str, 'content=\"') + 1;
	$end = strpos($str, "\"");
	$keyword = substr($str,$start,$end, - $start);
	$keys = explode(",", $keyword);
	
}
	for($i=0;$i<count($keys); $i++) 
	{ echo $keys[$i]."<br/>";
}

else { 

?>
<html>
<head>
</head>
<body>
<form method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
url: <input type="text" name="url"/><br/>
<input type="submit" name="submit" value="submit"/>
</form>
</body>
</html>
<? } ?>
Error: arse error: syntax error, unexpected T_ELSE in C:\wamp\www\test.php on line 21
__________________
no signature set
sarmenhb is offline  
Reply With Quote