| Pablo M. Rivas 2004-07-26, 3:56 pm |
| Hello Philip,
read:
http://www.php.net/manual/en/function.mysql-result.php
when you do $queryResult = mysql_result($queryResult,0) you get
the error... so, you can do something like this:
function getMysqlSelectResultForUsername($identif
ier, $userName, $link)
{
$queryResult = mysql_query("select $identifier from theTable where
username = '$userName'", $link);
if ($queryResult) {
$queryResult = mysql_result($queryResult, 0);
}
return $queryResult;
}
$hall = getMysqlSelectResultForUserName('buildin
gID', $_userName,$link);
if (!$hall) die ("error")
....
or you can do:
function getMySqlSelectResultForUserName($identif
ier,
$userName,$link) {
return mysql_query("select $identifier from TheTable where
username='$userName'",$link);
}
$hall= getMysqlSelectResultForUsername('buildin
gID', $_userName, $link);
if (!$hall) die("not found building!!!");
$roomNum = getMysqlSelectResultForUsername('roomNum
', $_userName,$link);
$phone1 = getMysqlSelectResultForUsername('phone1'
, $_userName, $link);
$phone2 = getMysqlSelectResultForUsername('phone2'
, $_userName, $link);
$lastLogin = getMysqlSelectResultForUsername('lastLog
in', $_userName,$link);
if ((!$roomNum) or (!$phone1) or (!$phone2) or (!$lastLogin)) {
echo "data is missing";
.... ....
} else {
.......
}
PT> Pablo,
--
Best regards,
Pablo
|