0

I get an error

Undefined index: value

on the line $search_value = $_GET['value'];.

I'm trying to create a basic search engine with PHP and MySQL.

mysql_connect($db_hostname, $db_username, $db_password);
mysql_select_db($db_database);


 if(isset($_GET['search'])){

        $search_value = $_GET['value'];

        $query = "select * from backedupdata where descr like '%$search_value%'";

        $run = mysql_query($query);

            while($row = mysql_fetch_array($run)){

                $hddn = $row['hddno'];
                $dat = $row['date'];
                $cover = $row['coverc'];
                $desc = $row['descr'];

                echo "<h2>Date: $dat</h2><br /><h3>Hdd No: $hddn</h3><br /><h3>Cover Colour: $cover</h3><br /><h3>Description:</h3><p>$desc</p><hr>";

            }

    }

What's wrong?

Ulfalizer
  • 4,664
  • 1
  • 21
  • 30

2 Answers2

1

Try with -

if(isset($_GET['search']) && !empty($_GET['value'])){ ... }
Sougata Bose
  • 31,517
  • 8
  • 49
  • 87
1

You have this error because your page have no field called value in $_GET

Try to display what your $_GET[] contains using this :

print_r ($_GET);

or

var_dump ($_GET);

or you can add a test in your if clause :

if(isset($_GET['search']) && isset($_GET['value'])){
...
Seblor
  • 6,947
  • 1
  • 25
  • 46