I have this function and it doesnt yield client id but instead something like this 'Resource id#4'. What should i do? function getKlientID($username) { $sql = "select clientID from clients where username='$username"; $result = mysql_query($sql); return $result; }
mysql_query returns a result resource, not the result of the query. http://php.net/mysql_query http://php.net/mysql_fetch_assoc http://php.net/mysql_result
Just add these lines after your $result = mysql_query($sql); $result = mysql_fetch_assoc($result); $result = $result['clientID']; return $result; PHP: That should do the trick