Re: Empty query result

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Why not...??

if (!($queryResult =
mysql_result($queryResult, 0)))
{
	return 0;
}
----- Original Message -----
From: Philip Thompson <prthomp@xxxxxxxx>
Date: Monday, July 26, 2004 12:57 pm
Subject: Re:  Empty query result

> Pablo,
> 
> > Hello Philip,
> >
> >     pse.. can you paste the error information?
> >     There is no known "empty set" problem.
> >
> Here's my function:
> 
> function
getMysqlSelectResultForUsername($identifier,
$userName, 
> $link){
>     $queryResult = mysql_query("select $identifier
from theTable 
> where 
> username = '$userName'", $link);
> 
>     if (!($queryResult =
mysql_result($queryResult, 0))) {
>        
session_register('_selectIdentifierFromTheTable');
>         header("location:error.php");
>         exit;
>     }
> 
>     return $queryResult;
> }
> 
> Here's the code that calls it:
> 
> $hall =
getMysqlSelectResultForUsername('buildingID',
$_userName, 
> $link);
> $roomNum =
getMysqlSelectResultForUsername('roomNum',
$_userName, 
> $link);
> $phone1 =
getMysqlSelectResultForUsername('phone1',
$_userName, 
> $link);$phone2 =
getMysqlSelectResultForUsername('phone2', 
> $_userName, $link);
> $lastLogin =
getMysqlSelectResultForUsername('lastLogin', 
> $_userName, 
> $link);
> 
> If the mysql_result($queryResult, 0) returns
zero/nothing, then it 
> goes 
> to the 'error.php' page. However, I just want it
to move on. For 
> example, if there is no 'phone2' given in the
database, I want it 
> to 
> just assign $phone2 to zero/nothing, not go to the
error page.
> 
> Hope this helps.
> 
> Thanks,
> ~Philip
> 
> > -- 
> > Best regards,
> >  Pablo
> > PT> Hi all.
> >
> > PT> I am querying a database of single
information multiple times 
> > using a
> > PT> simple 'select' statement. However, whenever
the data in the 
> DB is
> > PT> empty or is 0 (zero), then it throws an
error. However, I 
> don't 
> > want it
> > PT> to throw an error, I just want it to move on
to the next query.
> >
> > PT> This is being shown on a webpage I have.
Note that I am using a
> > PT> function for this select statement because I
just have to 
> change 
> > the
> > PT> identifier that I am looking for - saves
space. So I don't use
> > PT> mysql_error() to show my errors, I redirect
to a global 
> 'error' 
> > page.
> >
> > PT> Is there a way to get around this "empty
set" problem? Yes, I 
> know> PT> about using @ to suppress warnings, but
it's more than this.
> >
> > PT> Thanks a bunch,
> > PT> ~Philip
> >
> > -- 
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit:
http://www.php.net/unsub.php
> >
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux