Jump to content

troubled query


tet3828

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.