Търсачка в текстов файл

$file = "news.txt"; //файла, в който ще търсиш
$keyword = "asd"; //думата , която търсиш
$begin = file_get_contents("file.txt");
preg_match("/".$keyword."/", $begin, $matches);
print_r($matches);
 
Код:
<?php 
if(isset($_POST['submit')){ 
$file = "cutenews/data/news.txt"; //файла, в който ще търсиш 
$keyword = $_POST['keyword']; //думата , която търсиш 
$begin = file_get_contents("cutenews/data/news.txt"); 
preg_match("/".$keyword."/", $begin, $matches); 
print_r($matches); "; 
} else { 
?> 
<form action="search1.php" method="post"> 
<input type="text" name="keyword" class="searchs" value="   Търси..." onfocus="this.value='';" onblur="if(this.value=='')this.value='  Търси...';" /> 
<input class="searches" type="submit" value="" name="submit" /> 
</form> 
<?php 
} 
?>

Този код редктиран от emagi
дава този резултат:

Код:
Parse error: syntax error, unexpected ')', expecting ']' in public_html/proekt/search1.php on line 2
 
<?php
if(isset($_POST['submit'])){
$file = "cutenews/data/news.txt"; //файла, в който ще търсиш
$keyword = $_POST['keyword']; //думата , която търсиш
$begin = file_get_contents("cutenews/data/news.txt");
preg_match("/".$keyword."/", $begin, $matches);
print_r($matches); ";
} else {
?>
<form action="search1.php" method="post">
<input type="text" name="keyword" class="searchs" value="   Търси..." onfocus="this.value='';" onblur="if(this.value=='')this.value='  Търси...';" />
<input class="searches" type="submit" value="" name="submit" />
</form>
<?php
}
?>
 
emagi каза:
<?php
if(isset($_POST['submit'])){
$file = "cutenews/data/news.txt"; //файла, в който ще търсиш
$keyword = $_POST['keyword']; //думата , която търсиш
$begin = file_get_contents("cutenews/data/news.txt");
preg_match("/".$keyword."/", $begin, $matches);
print_r($matches); ";
} else {
?>
<form action="search1.php" method="post"><input type="text" name="keyword" class="searchs" value="   Търси..." onfocus="this.value='';" onblur="if(this.value=='')this.value='  Търси...';" />
<input class="searches" type="submit" value="" name="submit" />
</form>
<?php
}
?>


Код:
Parse error: syntax error, unexpected T_STRING in public_html/proekt/search1.php on line 10
Премахвам 10 ред и ми дава грешка на следващият
 
bluesoleil каза:
emagi каза:
<?php
if(isset($_POST['submit'])){
$file = "cutenews/data/news.txt"; //файла, в който ще търсиш
$keyword = $_POST['keyword']; //думата , която търсиш
$begin = file_get_contents("cutenews/data/news.txt");
preg_match("/".$keyword."/", $begin, $matches);
print_r($matches); ";
} else {
?>
<form action="search1.php" method="post"><input type="text" name="keyword" class="searchs" value="   Търси..." onfocus="this.value='';" onblur="if(this.value=='')this.value='  Търси...';" />
<input class="searches" type="submit" value="" name="submit" />
</form>
<?php
}
?>


Код:
Parse error: syntax error, unexpected T_STRING in public_html/proekt/search1.php on line 10
Премахвам 10 ред и ми дава грешка на следващият
 

Back
Горе