problem in web php search engine

Anonymous
Anonymous's picture

hi,
i've try your php search engine script tutorial.
my problem is at
[CODE]
if ($numrows == 0)
{
echo "<h4>Results</h4>";
echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>";
}

i got this message error:
Parse error: parse error, unexpected '"', expecting ',' or ';' in c:\program files\apache group\apache\htdocs\supplier\phpsearch.php on line 53

so, can you help me to solve this problem.
i'll waiting for your reply.

Joined: 11/28/2008
Hello,Try replacing the line

Hello,

Try replacing the line with:

CODE
echo '<p>Sorry, your search: ' . $trimmed . ' returned zero results</p>';

Let me know if that fixed it.
Blessings,
LW

--
iLuke

azifa7980
Anonymous's picture
hi,thank you for your

hi,
thank you for your suggestion.
but i face another problem.

Parse error: parse error, unexpected $end in c:\program files\apache group\apache\htdocs\supplier\phpsearch.php on line 88

why i get this error?

i more question, is this code correct or not?

CODE
<a href="supplier/phpsearch.php?<? echo $vendor ?>">-<? echo $name ?></a><br>
<? echo $category ?><br>
Result Number: <? echo $count ?><br><br>
<?php
$count++;
?>
<? } ?>

please reply back to me ASAP.

Joined: 11/28/2008
Which line is line 88? That's

Which line is line 88? That's where the error is, will be easier to solve if we kow what line the problem occurs on.

azifa7980
Anonymous's picture
hi,ok now i show all the

hi,
ok now i show all the coding here.

CODE
<html>
<body>
<?php
$var=@$_GET['q'];
$trimmed=trim($var);

$dbase="supplier";
$table="supp";
mysql_connect("localhost", "", "");
@mysql_select_db($dbase) or die("unable to select database");

$field_to_search="field";
$query="select * from $table where $field_to_search LIKE \"%trimmed%\" ";
$result=mysql_query($query);
$count=mysql_numrows($result);
?>
<form name="search" method="get" action="<? $PHP_SELF ?>">
Search the database for:<input type="text" name="q">
<input type="submit" name="search" value="Search">
</form>
<?php
if($q == true)
{
exit;
}
elseif($q == false)
{
?>
<form name="search" method="get" action="<? $PHP_SELF ?>">
Search all the newsletters for
<input type="text" name="q">
<input type="submit" name="search" value="Search">
</form>
}
<?php
if($trimmed == "")
{
echo "<p>Please enter a search...</p>";
exit;
}
 if(!isset($var))
 {
 echo "<p>We don't seem to have a search parameter!</p>";
 exit;
 }
 
 $numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);
 
 if($numrows == 0)
 {
 echo "<h4>Results</h4>";
 echo '<p>Sorry, your search: ' . $trimmed . ' returned zero results</p>';
 }
 
 if(empty($s))
 {
 $s=0;
 }
 $result=mysql_query($query) or die("couldn't execute query");
 
 if($numrows > 1) { $return = "results"; }
 else { $return = "result"; }
 
 echo '<p>Your search for ' . $var . ' returned $numrows
 $return.</p>';
 
 $count = 1+$s;
 
 while($r=mysql_fetch_array($result))
 {
 $vendor=$r["vendor"];
 $email=$r["email"];
 $brand=$r["brand"];
 $category=$r["category"];
 
 $count++;  
 }
?>
Result Number: <? echo $count ?><br><br>
</body>
</html>

Parse error: parse error, unexpected $end in c:\program files\apache group\apache\htdocs\supplier\phpsearch.php on line 83

The error is shown after the </html> tag. i don't why? if there any mistake that i make? can you check for me.
thank you.

azifa7980
Anonymous's picture
sorry me again.i have another

sorry me again.
i have another problem but not about search engine.
i show you the coding and the error. hope you can fix my problem.

CODE
<?php if($HTTP_POST_VARS["username"]=="") {?>

Notice: Undefined index: username in c:\program files\apache group\apache\htdocs\supplier\index.php on line 1

Joined: 11/28/2008
I don't know much php but in

I don't know much php but in the second one isn't it supposed to have the form of:

if......then

Where's the then?

Sorry I'm not sure why it's throwing up the first error. I orginally thought mayarialbe $end hadn't been defined but in the code you've posted there is no mentionof $end. Is there any more code other than what you supplied?

Joined: 11/28/2008
That just means that

That just means that something was not closed and so the end of the script was never apparent to php.

Look for stuff like the following:

CODE
Result Number: <? echo $count ?><br><br>

There should be a ; in there

CODE
<? echo $count; ?>

you have a few places like that.

If you liked this post, you'll love The Open Source Ministry Forum
And, the Open Source Ministry Blog {

azifa7980
Anonymous's picture
hi,it's me again..i still get

hi,
it's me again..
i still get the same error as i mention to you last post.
i have give up to try this php search engine coding.
anyway, thank you so much for your suggestion.

Joined: 11/28/2008
Why don't you just download a

Why don't you just download a ready made one and compare it to the one your trying to code? get it in the end, don't give up!

azifa7980
Anonymous's picture
hi,thank you for your advise.

hi,
thank you for your advise. but if you can help me, please tell me where can i get the download a ready made one of serach engine using php?
thank you.

Joined: 11/28/2008
HotscriptsPHP Resource Index
azifa7980
Anonymous's picture
hi,thank you for your

hi,
thank you for your suggestion website. i'ii try use the sample script that i've download.

Joined: 01/26/2011
Free PHP Search Engine

Recommend a free PHP search engine script:
Sphinx is a free open-source SQL full-text PHP search engine designed from the ground up with performance, relevance (aka search quality), and integration simplicity in mind.

Sphinx lets you either batch index and search data stored in an SQL database, NoSQL storage, or just files quickly and easily — or index and search data on the fly, working with Sphinx pretty much as a database server. A variety of text processing features enable fine-tuning Sphinx for your particular application requirements, and a number of relevance functions ensures you can tweak search quality as well.