Re: Empty query result

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

 



Thanks all! I will try some of the suggestions that you guys gave. I appreciate it.

~Philip


On Jul 26, 2004, at 12:52 PM, Pablo M. Rivas wrote:

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

--
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