MySQL database issue
Posted: Tue Aug 12, 2008 9:49 pm
Didn't want to keep spinning my wheels pointlessly, so I was hoping you guys could tell me what is going on.
this is printing out the following:
Select orig from md5 where md5_hash = 'ae2b1fca515949e5d54fb22b8ed95575' LIMIT 1
result: Resource id #2
in here 2
As you can see by the query, my variables were set correctly. I ran this query in cmd prompt and it returns a null set, so there are no issues with the query statement. So, any idea why this is returning something, when it should return null?
Btw, my db table is completely empty, nothing in it!
Edit: Also, you can see that the row does not print the 'orig' even though it should if result returned something!
Code: Select all
$q = "Select orig from ".$dbtable." where md5_hash = '".$encoded."' LIMIT 1";
echo "<br>".$q."<br>";
$result = mysql_query($q);
echo "result: ".$result."<br>";
if(!$result){
echo "in here";
$to_encode = mysql_real_escape_string($to_encode);
$q = "Insert into ".$dbtable." (orig,md5_hash) values ('".$to_encode."','".$encoded."')";
mysql_query($q) or die(mysql_error());
}
else{
echo "in here 2";
$row = mysql_fetch_array($result);
echo $row['orig'];
}
Select orig from md5 where md5_hash = 'ae2b1fca515949e5d54fb22b8ed95575' LIMIT 1
result: Resource id #2
in here 2
As you can see by the query, my variables were set correctly. I ran this query in cmd prompt and it returns a null set, so there are no issues with the query statement. So, any idea why this is returning something, when it should return null?
Btw, my db table is completely empty, nothing in it!
Edit: Also, you can see that the row does not print the 'orig' even though it should if result returned something!