I am a beginner and try to have a very simple messaging system. every thing is managed via the ID's of the users..
So if someone types the username of a person i have to convert it into the person's id:
$res_name = $_POST["res_name"];
$res_id = userToId($res_name);
This function looks like this:
function userToId($username) {
$data = array();
$func_get_args = func_get_args();
if($func_num_args = 1)
{
$res = mysql_query("SELECT id FROM `z_network_users` WHERE `username` = `$username`") or die(mysql_error());
$data = mysql_fetch_assoc($res);
}
return $data['id'];
}
it doesn't work, in fact it can't find a username even if it's existing..
the error is for example:
Unknown column 'testperson' in 'where clause'
the user exists, hope you can help me :) ps: I know I shouldn't use mysql_* but i haven' learned the better version.. ;)