Search code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alina_costin
Forum Newbie
Posts: 5
Joined: Fri Mar 05, 2004 1:02 am
Location: Romania
Contact:

Search code

Post by alina_costin »

HI ! Again me !
I have a search code with name search.php

****** begin code
<HTML>
<?php
$searchstring=$_GET['searchstring']
if ($searchstring)
{
$db=mysql_connect("localhost","root","") ;
mysql_select_db("test",$db) ;
$sql=" select * from personnel where $searchtype like '%$searchstring%' order by firstname ASC";
$result=mysql_query($sql,$db) ;
echo "<TABLE BORDER=2>" ;
echo "<TR><TD><B>Full Name</B><TD><B>Nick Name</B><TD>Options<B></B></TR>" ;
while ($myrow=mysql_fetch_array($result))
{
echo "<TR><TD>".$myrow["firstname"]."".$myrow["nick"] ;
echo "<TD><a ref=\"view.php?id=".$myrow["id"]."\" >View</a>" ;
}
echo "</TABLE>" ;
}
else
{
?>
<form method="POST" action="<?php $PHP_SELF ?>">
<table broder="2" cellspacing="2">
<tr><td>Insert your search string here</td>
<td>Search type</td></tr>
<tr>
<td><input type="text" name="searchstring" size="28"></td>
<td><select size="1" name="searchtype">
<option value="firstname" selected>First name</option>
<option value="lastname">Last name</option>
<option value="nick">Nick name</option>
<option value="email">Email</option>
</select>
</td>
</tr>
</table>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset"></p>
</form>
<?
}

?>
</HTML>

**********end code

when i browse it "http://localhost/search.php" i get an error :
"Parse error: parse error, unexpected T_IF in C:\Inetpub\wwwroot\search.php on line 4" ...something i swrong on the line "if ($searchstring)"

Thanks !
Allin1Joe
Forum Newbie
Posts: 4
Joined: Sat Sep 13, 2003 12:17 am
Location: Minneapolis, MN
Contact:

Post by Allin1Joe »

Nothing is wrong with your IF statement .. just the line above...

$searchstring=$_GET['searchstring']

No semi-colon
Post Reply