My web site stopped search since i hosted

My web site cant search since i hosted but it previously worked fine on my xampp locaholost
the url is www.technestng.com and whatever that is being searched does’nt return any result

here is some of the codes i used.

 <?php
$button = $_GET ['submit'];
$search = $_GET ['search']; 
$button = mysql_real_escape_string($button);

if(!$button)
echo "You didn't submit a keyword!<br><br>
<ul>
<li>
Search with a general words. For example: If you want to search 'how to create a website'
then use general keyword like 'create' or 'website'</li>
<li> Try different words with similar meaning</li>
<li> Please check your spelling</li></ul>";
else
{
if(strlen($search)<=1)
echo "Search term too short";
else{
echo "You searched for ''<b style='color:#337ab7;'>$search</b>'' <hr size='1'></br>";
include('includes/config2.php'); 
$search_exploded = explode (" ", $search);
foreach($search_exploded as $search_each)
{
$x++;
if($x==1)
$construct .="postTitle LIKE '%$search_each%'";
else
$construct .="AND postTitle LIKE '%$search_each%'";
}
$construct ="SELECT * FROM blog_posts_seo WHERE $construct";
$run = mysql_query($construct);
 
$foundnum = mysql_num_rows($run);
 
if ($foundnum==0)
echo "Sorry, there are no matching result for <b style='color:#337ab7;'>$search</b>.</br></br>
<ul>
<li>
Try more general words. for example: If you want to search 'how to create a website'
then use general keyword like 'create' 'website'</li>
<li> Try different words with similar meaning</li>
<li> Please check your spelling</li>";
else
{
echo "<b>$foundnum results found !</b><p>";
 
while($runrows = mysql_fetch_assoc($run))
{
$slug = $runrows['postSlug'];
$title = $runrows ['postTitle'];
}

You are using outdated mysql_ calls which your host probably doesn’t support. You should be using mysqli_ or PDO.

Oh i never thought of that!
but i actually tried writing it using pdo but i failed, i’m not that good afterall

Well, PDO needs thing about differently but will pay dividends in the end.

Ideally you should have the same versions of PHP and MySQL on your localhost as your host uses.

well thanks alot, atleast now i know where the problem is.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.