I am creating a logon page and I have some code that checks to see if any records are returned.
Now I use 'isset' to check but of course it gets set, so my quesion is, how do you check to see that a result set is returned without printing to screen. exampl:
$query = "select * from me_t where name=' ".$name." ' ";
if(isset($query)){
echo "query gets set";
}
Now I know I am using the wrong function but which one tells me that a record is returned?? I would send my whole code, however I am at work and do not have access to it at the moment
No records returned problem
Moderator: General Moderators
Try something like:
Code: Select all
<?
// Connect to MySQL
// Select table
$sql = mysql_query("SELECT * FROM `me_t` WHERE `name` = '{$name}'") or die("Unable to select from table `me_t`, error: " . mysql_error());
// Count results
$num_results = mysql_num_rows($sql);
// return true
if ($num_results > 0)
{
// User is in database
} else {
// User is not in database
}
?>When I go into production, I will make the transition into mySQL... but right now I am using an access database.
Eventually I will make the switch, but for now I have to make due. Any other suggestions, besides get a new database???
phice wrote:Try something like:
Code: Select all
<? // Connect to MySQL // Select table $sql = mysql_query("SELECT * FROM `me_t` WHERE `name` = '{$name}'") or die("Unable to select from table `me_t`, error: " . mysql_error()); // Count results $num_results = mysql_num_rows($sql); // return true if ($num_results > 0) { // User is in database } else { // User is not in database } ?>
