title: php mySQL returns an empty query
body: <p>I'm trying to create a billing history page where users can see a table with their purchase history in table format.  I'm trying to add a link to each row so that users can see the full invoice details for each order.</p>
  
  <p>When they click on the link (I've included the script for the overview page after this script) this script is supposed to execute the query but I'm just getting an empty message query.</p>
  
  <p>Can anyone spot the error?</p>
  
  <p>Thanks!!</p>
  
  <p>Eugenie</p>
  
  <pre><code>&lt;?php
  
  include("mainfile.php");
  include(XOOPS_ROOT_PATH."/header.php");
  
  
  $host="localhost"; // Host name 
  $username="user"; // Mysql username 
  $password="pass"; // Mysql password 
  $db_name="db"; // Database name 
  $tbl_name="table"; // Table name
  
  // Connect to server and select database.
  mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
  mysql_select_db("$db_name")or die("cannot select DB");
  
  // get value of id that sent from address bar
  $TicketID=$_GET['TicketID'];
  
  // Retrieve data from database 
  $sql="SELECT * FROM $tbl_name WHERE TicketID='$TicketID'";
  $result=mysql_query($sql);
  $rows=mysql_fetch_array($result);
  
  
  // Get a specific result from the "example" table
  $result = mysql_query($Sql) or die(mysql_error());
  
  
  echo "&lt;table width='100' border='1' cellpadding='0' cellspacing='0' id='records'&gt;";
  print "&lt;h3 align='center'&gt;&lt;strong&gt;Billing History&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;";
  echo "&lt;tr&gt;  
  &lt;th width='110' align='center'&gt;Billing Date&lt;/th&gt;
  &lt;th width='80' align='center'&gt;Ticket #&lt;/th&gt;  
  &lt;th align='center'&gt;Project Title &lt;/th&gt;
  &lt;th width='80' align='center'&gt;Total GBP&lt;/th&gt;
  
  
  
  &lt;/tr&gt;";
  // keeps getting the next row until there are no more to get
  while($row = mysql_fetch_array( $result )) {
  // Print out the contents of each row into a table
  echo "&lt;tr height='22' width='100' bordercolor='343434' align='center'&gt;&lt;td&gt;"; 
  echo $row['date'];
  echo "&lt;/td&gt;&lt;td&gt; "; 
  echo $row['TicketID'];
  
  echo "&lt;/td&gt;&lt;td&gt; "; 
  echo $row['project'];
  echo "&lt;/td&gt;&lt;td&gt; "; 
  echo $row['grandTotal'];
  
  
  } 
  
  echo "&lt;/table&gt;";
  
  include(XOOPS_ROOT_PATH."/footer.php");
  
  ?&gt;
  </code></pre>
  
  <p>This is the script that displays the full billing history and that contains the link with the script that executes the query (above).</p>
  
  <pre><code>&lt;?php
  
  include("mainfile.php");
  include(XOOPS_ROOT_PATH."/header.php");
  
  
  $host="localhost"; // Host name 
  $username="username"; // Mysql username 
  $password="password"; // Mysql password 
  $db_name="db name"; // Database name 
  $tbl_name="tbl name"; // Table name 
  
  // Connect to server and select database.
  mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
  mysql_select_db("$db_name")or die("cannot select DB");
  
  $sql="SELECT * FROM $tbl_name  WHERE uid='";
  $sql=$sql .  $xoopsUser-&gt;uid("s") . "'  AND Paid='Y'";
  
  
  $result=mysql_query($sql);
  ?&gt;
  
  &lt;table width="400" border="0" cellspacing="1" cellpadding="0"&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;table width="400" border="1" cellspacing="0" cellpadding="3"&gt;
  &lt;tr&gt;
  &lt;td colspan="4"&gt;&lt;strong&gt;List data from mysql &lt;/strong&gt; &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td align="center"&gt;&lt;strong&gt;Billing Date&lt;/strong&gt;&lt;/td&gt;
  &lt;td align="center"&gt;&lt;strong&gt;Invoice Number&lt;/strong&gt;&lt;/td&gt;
  &lt;td align="center"&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/td&gt;
  &lt;td align="center"&gt;&lt;strong&gt;Total GBP&lt;/strong&gt;&lt;/td&gt;
  &lt;td align="center"&gt;&lt;strong&gt;View&lt;/strong&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;?php
  while($rows=mysql_fetch_array($result)){
  ?&gt;
  
  &lt;tr&gt;
  &lt;td&gt;&lt;? echo $rows['date']; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;? echo $rows['TicketID']; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;? echo $rows['project']; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;? echo $rows['grandTotal']; ?&gt;&lt;/td&gt;
  
  
  &lt;td align="center"&gt;&lt;a href="http://website.co.uk/site/viewInvoice.php?TicketID=&lt;? echo     $rows['TicketID']; ?&gt;"&gt;View&lt;/a&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;?php
  }
  ?&gt;
  
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;?php
  mysql_close();
  include(XOOPS_ROOT_PATH."/footer.php");
  ?&gt;    
  </code></pre>