PDA

View Full Version : Not displaying result


dmccabe2
Tue 20th Apr '04, 11:37am
Can someone help its not displaying my on/off images I just get an error saying "auth is empty dammit! "

DB Structure

table name : auth

======
| auth |
--------
| on |
--------



<?

$sql = "SELECT * FROM auth";

$conn = mysql_connect('localhost', 'usr', 'pw') or print mysql_error();
mysql_select_db('chat', $conn);

$result = mysql_query($sql, $conn) or print mysql_error();
while ($row = mysql_fetch_array($result)) {
$auth = $row['auth'];


if (!$auth || $auth == null) {$auth = "auth is empty dammit!";}

if ($auth == 'off') {

$access = "<img src='../lobby/images/off.gif'>Open access is off you must register";

} elseif ($auth == 'on') {

$access = "<img src='../lobby/images/on.gif'>Open Access is on";

} else {

$access = "error -- $auth";

}

}

echo "$access";

?>

Lats
Tue 20th Apr '04, 1:25pm
Try...
$auth = $row['auth'];

dmccabe2
Tue 20th Apr '04, 1:54pm
Just changed the code to refelct that but still says error -- auth is empty dammit! :(

Lats
Tue 20th Apr '04, 2:19pm
I copied your updated code and it runs with the result of "Open Access is on" using this test database...
#
# Table structure for table `auth`
#
CREATE TABLE `auth` (
`auth` char(3) NOT NULL default ''
) TYPE=MyISAM;
#
# Dumping data for table `auth`
#
INSERT INTO `auth` VALUES ('on');

dmccabe2
Tue 20th Apr '04, 2:32pm
really damn must be my table then i will delete it and create it again, thanks for your help:)