Mysqli db search engine problems

I have been trying to get this and many others like it to work. the issue is when I submit for the search I go to a blank page… I have worked out all the kinks other than this one and it has been reoccuring regardless of which search engine code I use… Someone please help!!!
[php]

<?PHP function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } //initializing connection to the database $connection_string = dirname(__FILE__) . "/connectionstring.php"; require_once($connection_string); //selecting table mysqli_select_db($conn, $DB_NAME) or die ( 'Unable to select database.' ); //max number of results on the page $RESULTS_LIMIT=10; if(isset($_GET['search_term']) && isset($_GET['search_button'])) { $search_term = $_GET['search_term']; if(!isset($first_pos)) { $first_pos = "0"; } $start_search = getmicrotime(); //initializing mysqli Quary $sql_query = mysqli_query("SELECT * FROM news WHERE MATCH(title,article) AGAINST('$search_term')"); //additional check. Insurance method to re-search the database again in case of too many matches (too many matches cause returning of 0 results) if($results = mysqli_num_rows($sql_query) != 0) { $sql = "SELECT * FROM news WHERE MATCH(title,article) AGAINST('$search_term') LIMIT $first_pos, $RESULTS_LIMIT"; $sql_result_query = mysqli_query($sql); } else { $sql = "SELECT * FROM news WHERE (title LIKE '%".mysqli_real_escape_string($search_term)."%' OR article LIKE '%".$search_term."%') "; $sql_query = mysqli_query($sql); $results = mysqli_num_rows($sql_query); $sql_result_query = mysqli_query("SELECT * FROM news WHERE (title LIKE '%".$search_term."%' OR article LIKE '%".$search_term."%') LIMIT $first_pos, $RESULTS_LIMIT "); } $stop_search = getmicrotime(); //calculating the search time $time_search = ($stop_search - $start_search); } ?> <?PHP if($results != 0) { ?> <?PHP while($row = mysqli_fetch_array($sql_result_query)) { ?> <?PHP } ?>
Results for <?PHP echo "".$search_term." "; ?> Results <?PHP echo ($first_pos+1)." - "; if(($RESULTS_LIMIT + $first_pos) < $results) echo ($RESULTS_LIMIT + $first_pos); else echo $results ; ?> out of <?PHP echo $results; ?> for(<?PHP echo sprintf("%01.2f", $time_search); ?>) seconds
<?PHP echo $row['title']; ?>
<?PHP } //if nothing is found then displays a form and a message that there are nor results for the specified term elseif($sql_query) { ?>
No results for <?PHP echo "".$search_term." "; ?>
<?PHP } ?> <?php if (!isset($_GET['search_term'])) { ?> <?php } ?>
<?PHP //displaying the number of pages where the results are sittuated if($first_pos > 0) { $back=$first_pos-$RESULTS_LIMIT; if($back < 0) { $back = 0; } echo ""; } if($results>$RESULTS_LIMIT) { $sites=intval($results/$RESULTS_LIMIT); if($results%$RESULTS_LIMIT) { $sites++; } } for ($i=1;$i<=$sites;$i++) { $fwd=($i-1)*$RESULTS_LIMIT; if($fwd == $first_pos) { echo "$i | "; } else { echo "$i | "; } } if(isset($first_pos) && $first_pos < $results-$RESULTS_LIMIT) { $fwd=$first_pos+$RESULTS_LIMIT; echo " >>"; $fwd=$results-$RESULTS_LIMIT; } ?>
[/php]

When you’re developing you should make sure your local dev environment is set up to show all errors. A white page is what PHP defaults to when it hits any “500 internal server error” that isn’t properly handled by the application.

An easy way to activate all is to add this to the beginning of your script
[php]error_reporting(E_ALL);
ini_set(‘display_errors’, 1);[/php]

Though this should really be changed in your local php.ini

Sponsor our Newsletter | Privacy Policy | Terms of Service