simple mysql_result() question

From: Date: Thu, 08 Apr 2004 01:29:11 +0000
Subject: simple mysql_result() question
Groups: php.general 
Request: Send a blank email to php-general+get-182766@lists.php.net to get a copy of this message
hello, I am trying to authenticate users. I run this MySQL query using vars provided via a form.... select password from dealers where username = '$user' this works great if $user is actually a user in the database. otherwise i get this error.... Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3 in /var/www/php/AuthTool.php on line 52 its because of this.... $thePass = mysql_result($result,'0','password'); is there a way to stop this error, should i be using mysql_fetch_array instead? Code below. Thanks, jd function auth(){ $user = $_POST['user']; $pass = $_POST['pass']; $query = "select password from dealers where username = '$user'"; $result = $this->sqlQuery($query); if(!$result){ echo "Sorry there was a error\n"; } else{ $thePass = mysql_result($result,'0','password'); if($thePass){ echo "$thePass\n"; } else{ echo "no such user - $user\n"; } } } -- jd@taproot.bz "Bad spellers of the world untie!"

« previous php.general (#182766) next »