why can't I run two mysql query's in the same php script?

I can only seem to Run one at a time. both are in the same database. the webapp I'm making stores the user data in a sql table. then I was planning on using another table to store the users password. the problem is I can get the php script to either query for the password or for the user data but not bouth. can't figure out why. I tried using the "mysql_free_result();" command in between but that doesn't help either.

$con = mysql_connect("me.com","giftcards","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("giftcards", $con);
//-- password --
$sql="SELECT * FROM `passwords` WHERE `UID` = '".$_POST["uid"]."'";
$presult = mysql_query($sql,$con);
$row=mysql_fetch_row($presult);
if($row[1]!=$_POST["password"])
{
mysql_close($con);
die("<script>alert('Bad Username or Password');document.location.href='index.htm';</script>");
}
mysql_free_result($presult);
$sql = "SELECT * FROM "'.$_POST["uid"];
echo $sql."<br>";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo "<tr align=center><td>".$row['Card ID'] . "</td><td>" . $row['Amt']."</td>";
echo "<td><img src=pen.png onclick=edit('".$row['Card ID']."')><img src=x.png onclick=nuke('".$row['Card ID']."')>";
echo "</td></tr>";
}
mysql_close($con);

now I can get it to validate the password properly, but it doesn't show any of the data in the user table
I used php myadmin to check the table is there and there is data in it.
Also if I commet out the password Checking, but change nothing else then it shows the data in the user data. so I can't figure out what I'm missing it acts the same weather or not i got the mysql_free_result(); line there. I can't get it to access data from bouth tables. what am I missing??
 
Back
Top