title: How to retrieve data from database?
body: <p>I can't retrieve the product's name, description, price and picture,here's the code and I don't get anything except the: Pice: and the button Add To Cart. When i run the var_dump($row) after the name, picture, description and price, it returns me NULL on the browser.</p>
  
  <pre><code>&lt;?
  require "C:/xampp/htdocs/shopping/shopping/includes/db.php";
  require "C:/xampp/htdocs/shopping/shopping/includes/functions.php";
  
  if($_REQUEST['command']=='add' &amp;&amp; $_REQUEST['productid']&gt;0){
      $pid=$_REQUEST['productid'];
      addtocart($pid,1);
      header("location:shoppingcart.php");
      exit();
  }
       ?&gt;
      &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
      &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
       &lt;head&gt;
     &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
        &lt;title&gt;Products&lt;/title&gt;
       &lt;script language="javascript"&gt;
  function addtocart(pid){
      document.form1.productid.value=pid;
      document.form1.command.value='add';
      document.form1.submit();
  }
    &lt;/script&gt;
    &lt;/head&gt;
  
  
   &lt;body&gt;
   &lt;form name="form1"&gt;
  &lt;input type="hidden" name="productid" /&gt;
      &lt;input type="hidden" name="command" /&gt;
    &lt;/form&gt;
      &lt;div align="center"&gt;
  &lt;h1 align="center"&gt;Products&lt;/h1&gt;
  &lt;table border="0" cellpadding="2px" width="600px"&gt;
      &lt;?
          $result=mysql_query("SELECT * FROM products");
          while($row=mysql_fetch_array($result)){
      ?&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;img src="&lt;?=$row['picture']?&gt;" /&gt;&lt;/td&gt;
          &lt;td&gt;    &lt;b&gt;&lt;?=$row['name']?&gt;&lt;/b&gt;&lt;br /&gt;
                  &lt;?=$row['description']?&gt;&lt;br /&gt;
                  Price:&lt;big style="color:green"&gt;
                      $&lt;?=$row['price']?&gt;&lt;/big&gt;&lt;br /&gt;&lt;br /&gt;
                  &lt;input type="button" value="Add to Cart" onclick="addtocart(&lt;? =$row['serial']?&gt;)" /&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;&lt;td colspan="2"&gt;&lt;hr size="1" /&gt;&lt;/td&gt;
      &lt;? } ?&gt;
    &lt;/table&gt;
    &lt;/div&gt;
    &lt;/body&gt;
    &lt;/html&gt;
  </code></pre>
  
  <p>[edit]
  db.php</p>
  
  <pre><code>&lt;?
  mysql_connect("localhost","root","") or die("DB error");
  mysql_select_db("shopping") or die("DB error");
  session_start();
  
  ?&gt;
  </code></pre>