0

Ave! There's my issue. Everything works at localhost. There's an button on the webside:

<INPUT Type="BBUTTON" Value="go to search engine" Onclick="window.location.href='http://localhost/public_html/search/'">

There's a code like this (double B above I pressed cause there was error during porting here. Normally is one b).

Files in folder search:

index.php

There the line like this:

   <form method="get" action="results.php">
    <input type="text" name="search"><br>

Next:

    >     <?php  
> 
> 
> 
> header("Content-Type: text; charset=utf-8"); 
> mysql_connect("localhost","login","passtoadminside") or
> die(mysql_error());
> mysql_select_db("franklyIamnotsuremaybetableinmysqlname") or
> die(mysql_error());
> 
> 
> $clean = mysql_real_escape_string($_GET['search']); $hello =
> mysql_query("SELECT * FROM items WHERE description LIKE '%$clean%'")
> or die(mysql_error()); if (mysql_num_rows($hello) >= 1){  while($i =
> mysql_fetch_array($hello)) {      echo '<a
> href="'.$i['url'].'">'.$i['title'].'</a><p>'.$i['description'].'</p>';
>   } } else {  echo "Nothing.";  }
> 
> ?>

file result.hph

    <?php  



header("Content-Type: text; charset=utf-8"); 
mysql_connect("localhost","login","pass to adminside") or die(mysql_error());
mysql_select_db("franklyIamnotsuremaybetableinmysqlname") or die(mysql_error());


$clean = mysql_real_escape_string($_GET['search']);
$hello = mysql_query("SELECT * FROM items WHERE description LIKE '%$clean%'") or die(mysql_error());
if (mysql_num_rows($hello) >= 1){
    while($i = mysql_fetch_array($hello)) {
        echo '<a href="'.$i['url'].'">'.$i['title'].'</a><p>'.$i['description'].'</p>';
    }
}
else {
    echo "No hope";
 }

?>

I am stuck, whole page works fine, end of hope begins after pushing button. Works perfect with XAMPP on linux. I've been working on it for few weeks. I've just tried make search engine to my books collection. I trusted him: https://www.youtube.com/watch?v=gQs-TR5jdmU

Pax.

  • 1
    Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[a Kitten is strangled somewhere in the world](http://2.bp.blogspot.com/-zCT6jizimfI/UjJ5UTb_BeI/AAAAAAAACgg/AS6XCd6aNdg/s1600/luna_getting_strangled.jpg)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions and prepared statements. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly Feb 13 '17 at 03:57
  • Quite possibly your LIVE server has PHP7 installed. So the `mysql_` database extensions will not exist, therefore this code will not work – RiggsFolly Feb 13 '17 at 03:59
  • No way to defend. I love cats too. I was sure I am able to curry out my wish about search engine. Why it works to xampp on linux machine then? – Tee Kay Feb 13 '17 at 04:02

0 Answers0