profile system problem

Post here is you are having problems with any of the tutorials.
Post Reply
Insight223
Posts: 5
Joined: Tue Mar 13, 2012 5:31 am

profile system problem

Post 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!
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: profile system problem

Post 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.
Image
Post Reply