tet3828 Posted January 20, 2008 Share Posted January 20, 2008 My query is not returning any results however I know the my table tSession contains the value I am querying. I think I've got this query all wrong or something. please help $lName = $_POST['lName']; $sql = "SELECT * FROM tSession WHERE `lName` =`$lName`"; $result = mysql_query($qry) or die(mysql_error()); echo "the query $fName"; while($row = mysql_fetch_array($result)) { echo "the query $fName yeielded no results. ".$row['note'].""; } Link to comment https://forums.phpfreaks.com/topic/86869-troubled-query/ Share on other sites More sharing options...
Nhoj Posted January 20, 2008 Share Posted January 20, 2008 Change $sql = "SELECT * FROM tSession WHERE `lName` =`$lName`"; to $sql = "SELECT * FROM tSession WHERE `lName` = '{$lName}'"; You can't use ` to surround a value, only a column or table name Link to comment https://forums.phpfreaks.com/topic/86869-troubled-query/#findComment-444089 Share on other sites More sharing options...
tet3828 Posted January 20, 2008 Author Share Posted January 20, 2008 Strange. I don't know what the deal is. it is still coming back with an empty query. ??? Link to comment https://forums.phpfreaks.com/topic/86869-troubled-query/#findComment-444101 Share on other sites More sharing options...
Nhoj Posted January 20, 2008 Share Posted January 20, 2008 Are you positive there are row's in your table that have `lName` equal to $lName? Link to comment https://forums.phpfreaks.com/topic/86869-troubled-query/#findComment-444102 Share on other sites More sharing options...
trq Posted January 20, 2008 Share Posted January 20, 2008 Your not actually executing your query but some undefined $qry variable. Try... <?php $lName = $_POST['lName']; $sql = "SELECT * FROM tSession WHERE `lName` = '$lName'"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while($row = mysql_fetch_array($result)) { echo "the query $fName yeielded no results. " . $row['note']; } } else { echo "No results found"; } } else { echo "Query failed<br />$sql<br />" . mysql_error(); } ?> Link to comment https://forums.phpfreaks.com/topic/86869-troubled-query/#findComment-444105 Share on other sites More sharing options...
Nhoj Posted January 20, 2008 Share Posted January 20, 2008 Haha! I feel stupid.... Link to comment https://forums.phpfreaks.com/topic/86869-troubled-query/#findComment-444107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.