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'); } ?> ----------------------------------------------------------------------- Quote Link to comment Share on other sites More sharing options...
alexguz79 Posted April 15, 2008 Author Share Posted April 15, 2008 plis... anybody? Quote Link to comment Share on other sites More sharing options...
alexguz79 Posted April 15, 2008 Author Share Posted April 15, 2008 nobody? Quote Link to comment Share on other sites More sharing options...
conker87 Posted April 15, 2008 Share Posted April 15, 2008 What are lines 23-25? Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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'); } ?> Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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."; Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.