title: PHP undefined index - sortby
body: <p>Its basically displaying data from mysql database and using </p>
  
  <pre><code>$sortby = $_GET['sort'];
  </code></pre>
  
  <p>And the error I get is</p>
  
  <pre><code>Notice: Undefined index: sort in /home/4507408/public_html/list.php on line 8
  </code></pre>
  
  <p>Here is the full code, any ideas? (Line 8 is $sortby = $_GET['sort'];)</p>
  
  <p>Thanks for looking :)</p>
  
  <pre><code>&lt;?php
  $dbhost = 'localhost';
  $dbuser = 'CU4507408';
  $dbpass = 'adamadam1';
  $dbname = 'CU4507408';
  $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die("Error connecting to        database");
  mysql_select_db($dbname);
  $sortby = $_GET['sort'];
  ?&gt;
  </code></pre>
  
  <p>Thats at the top of the page</p>
  
  <pre><code>&lt;table border="1"&gt;
  
      &lt;tr&gt;
          &lt;th&gt;&lt;a href="list.php?sort=name"&gt;Product Name:&lt;/a&gt;&lt;/th&gt;
          &lt;th&gt;&lt;a href="list.php?sort=price"&gt;Price £&lt;/a&gt;&lt;/th&gt;
          &lt;th&gt;&lt;a href="list.php?sort=manufacturer"&gt;Manufacturer&lt;/a&gt;&lt;/th&gt;
          &lt;th&gt;&lt;a href="list.php?sort=rating"&gt;Rating&lt;/a&gt;&lt;/th&gt;
          &lt;th&gt;&lt;a href="list.php?sort=categoryname"&gt;Category&lt;/a&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;?php
      $query = "SELECT p.productID, p.name, p.price, p.manufacturer, p.rating, c.categoryname FROM product p INNER JOIN category c WHERE p.categoryID=c.categoryID ORDER BY $sortby ASC;";
      $result = mysql_query($query) or die("failed!");
      while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
          ?&gt;
          &lt;tr&gt;
  
              &lt;td&gt;&lt;a href="link.php?productID=&lt;?= $row['productID'] ?&gt;"&gt;&lt;?= $row['name'] ?&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?= $row['price'] ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?= $row['manufacturer'] ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?= $row['rating'] ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?= $row['categoryname'] ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
  &lt;? } ?&gt;
  </code></pre>