alexguz79 Posted April 15, 2008 Share Posted April 15, 2008 hey everybody.. trying to have this code working but allways give error on line 23-25 after the search, can anybody help me? Code: ----------------------------------------------------------------------------------------- <? if (isset($keywords) && $keywords != "") { $searchterms = $_GET["keywords"]; $query = "select * from perfect where match(nombre,texto) against('".mysql_real_escape_string($searchterms)."')"; $result = mysql_query($query); if ($row = mysql_fetch_array($result)) { print"<br /><b>Your search returned ".mysql_num_rows($result)." results.</b>"; $i = 1; do { print"<br /><br />This is search result number {$i}"; $i++; { while ($row = mysql_fetch_array($result)); } else { print"<br />Your search returned no results." } else { include('picture_search.php'); } ?> ----------------------------------------------------------------------- Link to comment https://forums.phpfreaks.com/topic/101196-solved-please-help-on-a-search-engine/ Share on other sites More sharing options...
alexguz79 Posted April 15, 2008 Author Share Posted April 15, 2008 plis... anybody? Link to comment https://forums.phpfreaks.com/topic/101196-solved-please-help-on-a-search-engine/#findComment-517650 Share on other sites More sharing options...
alexguz79 Posted April 15, 2008 Author Share Posted April 15, 2008 nobody? Link to comment https://forums.phpfreaks.com/topic/101196-solved-please-help-on-a-search-engine/#findComment-517705 Share on other sites More sharing options...
conker87 Posted April 15, 2008 Share Posted April 15, 2008 What are lines 23-25? Link to comment https://forums.phpfreaks.com/topic/101196-solved-please-help-on-a-search-engine/#findComment-517708 Share on other sites More sharing options...
soycharliente Posted April 15, 2008 Share Posted April 15, 2008 I assume 23-25 is the print line that he has in bold typeface. I could be wrong though. What does the error say? And please wrap your code in the tags. Link to comment https://forums.phpfreaks.com/topic/101196-solved-please-help-on-a-search-engine/#findComment-517711 Share on other sites More sharing options...
conker87 Posted April 15, 2008 Share Posted April 15, 2008 I cant see anything wrong with that code. Any errors please? Link to comment https://forums.phpfreaks.com/topic/101196-solved-please-help-on-a-search-engine/#findComment-517712 Share on other sites More sharing options...
alexguz79 Posted April 15, 2008 Author Share Posted April 15, 2008 this is the error i get after the search is made: Parse error: syntax error, unexpected T_ELSE in /home/mytrende/public_html/p_search.php on line 23 and the code is like this: <? if (isset($keywords) && $keywords != "") { $searchterms = $_GET["keywords"]; $query = "select * from perfect where match(nombre_evento,texto_evento) against('".mysql_real_escape_string($searchterms)."')"; $result = mysql_query($query); if ($row = mysql_fetch_array($result)) { print"<br /><b>Your search returned ".mysql_num_rows($result)." results.</b>"; $i = 1; do { print"<br /><br />This is search result number {$i}"; $i++; { while ($row = mysql_fetch_array($result)); } else { print"<br />Your search returned no results." } else { include('picture_search.php'); } ?> Link to comment https://forums.phpfreaks.com/topic/101196-solved-please-help-on-a-search-engine/#findComment-517718 Share on other sites More sharing options...
soycharliente Posted April 15, 2008 Share Posted April 15, 2008 On closer inspection of the code, you have some errors with your closing braces. You should really learn to format your code more cleanly. Here is your cleaned up code with the closing braces fixed. <?php if (isset($keywords) && $keywords != "") { $searchterms = $_GET["keywords"]; $query = "SELECT * FROM perfect WHERE MATCH(nombre,texto) AGAINST('".mysql_real_escape_string($searchterms)."')"; $result = mysql_query($query); if ($row = mysql_fetch_array($result)) { print "Your search returned ".mysql_num_rows($result)." results."; $i = 1; do { print "This is search result number {$i}"; $i++; } while ($row = mysql_fetch_array($result)); } else { print "Your search returned no results." } } else { include('picture_search.php'); } ?> If this is not the correct logic, I'm sorry, but it was hard to tell what statements went with which opening if statement. Link to comment https://forums.phpfreaks.com/topic/101196-solved-please-help-on-a-search-engine/#findComment-517720 Share on other sites More sharing options...
soycharliente Posted April 15, 2008 Share Posted April 15, 2008 1. The brace before the while statement was facing the wrong way. 2. You missed another closing brace at the end after the "no results found" print statement. Link to comment https://forums.phpfreaks.com/topic/101196-solved-please-help-on-a-search-engine/#findComment-517721 Share on other sites More sharing options...
alexguz79 Posted April 15, 2008 Author Share Posted April 15, 2008 thanks for trying to help... the code from charlieholder looks cleaner... but have the same error.... Parse error: syntax error, unexpected '}' in /home/mytrende/public_html/p_search.php on line 19 if anybody knows from a good search tutorial link... so i can check what i;m doing wrong Link to comment https://forums.phpfreaks.com/topic/101196-solved-please-help-on-a-search-engine/#findComment-517732 Share on other sites More sharing options...
soycharliente Posted April 15, 2008 Share Posted April 15, 2008 Post the code that you have now AND indicate which line is #19. It's a BASIC syntax error. No need for a tutorial. Link to comment https://forums.phpfreaks.com/topic/101196-solved-please-help-on-a-search-engine/#findComment-517743 Share on other sites More sharing options...
unidox Posted April 15, 2008 Share Posted April 15, 2008 Here: <? if (isset($keywords) && $keywords != "") { $searchterms = $_GET["keywords"]; $query = "select * from perfect where match(nombre_evento,texto_evento) against('".mysql_real_escape_string($searchterms)."')"; $result = mysql_query($query); if ($row = mysql_fetch_array($result)) { print"Your search returned ".mysql_num_rows($result)." results."; $i = 1; do { print"This is search result number {$i}"; $i++; } while ($row = mysql_fetch_array($result)); } else { print"Your search returned no results."; } } else { include('picture_search.php'); } ?> You were missing a trailing ; for print"Your search returned no results."; Link to comment https://forums.phpfreaks.com/topic/101196-solved-please-help-on-a-search-engine/#findComment-517792 Share on other sites More sharing options...
soycharliente Posted April 15, 2008 Share Posted April 15, 2008 Thanks unidox. Easy things to miss. Please mark SOLVED. Link to comment https://forums.phpfreaks.com/topic/101196-solved-please-help-on-a-search-engine/#findComment-517851 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.