Re[2]: [PHP-DB] Empty query result

From: Date: Mon, 26 Jul 2004 17:52:38 +0000
Subject: Re[2]: [PHP-DB] Empty query result
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-35465@lists.php.net to get a copy of this message
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($identifier, $userName, $link) { $queryResult = mysql_query("select $identifier from theTable where username = '$userName'", $link); if ($queryResult) { $queryResult = mysql_result($queryResult, 0); } return $queryResult; } $hall = getMysqlSelectResultForUserName('buildingID', $_userName,$link); if (!$hall) die ("error") .... or you can do: function getMySqlSelectResultForUserName($identifier, $userName,$link) { return mysql_query("select $identifier from TheTable where username='$userName'",$link); } $hall= getMysqlSelectResultForUsername('buildingID', $_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('lastLogin', $_userName,$link); if ((!$roomNum) or (!$phone1) or (!$phone2) or (!$lastLogin)) { echo "data is missing"; .... .... } else { ....... } PT> Pablo, -- Best regards, Pablo

« previous php.db (#35465) next »