Page 1 of 1

profile system problem

Posted: Thu Mar 15, 2012 7:17 am
by Insight223
Alright so I have the user login and profile pages working perfectly fine, but when I try to get the user_id from my database from the person logged in I get this error

Unable to jump to row 0 on MySQL result index 5

and it has to do with this code.
	
function fetch_current_user_id($username)
	{
		$username = mysql_real_escape_string($username);
		$sql = "SELECT `user_id` FROM `user_profiles` WHERE `user_username` = '{$username}'";
		$result = mysql_query($sql) or die(mysql_error());

		return mysql_result($result, 0) or die(mysql_error());
	}
the stupid thing just gives that error all over, it doesn't break anything but it gives the sql errors everywhere on every page, but it does give the uid correctly. I have messed around with the mysql_fetch_assoc and mysql_fetch_row and tried to use that as thats the data i got from googling the error and couldn't get it working, any help would be appreciated!

Re: profile system problem

Posted: Fri Mar 16, 2012 9:57 pm
by jacek
Well the error would indicate that there is no row in the table with that username :? Are you sure the error is coming from that query ? It could be another one, it seems odd that it would give the error but still work.