19.02.2014, 20:37
Hi,
I tried to create this function which is included to another page. It must return the ID of a user depending on the name of the user. This is the function:
This is how it is called:
The problem is that it doesn't return anything. I'm working on this issue for around an hour now and didn't find anything to solve it so far.. Anyone with ideas?
I tried to create this function which is included to another page. It must return the ID of a user depending on the name of the user. This is the function:
PHP код:
function GetUserID($AccName){
global $server;
global $user;
global $pw;
global $database;
$sql_query = mysqli_connect($server, $user, $pw, $database) or die("Error " . mysqli_error($sql_query));
$AccName = mysqli_real_escape_string($sql_query, $AccName);
$search = "SELECT UniqueID FROM Accounts WHERE UserName = '".$AccName."';";
if ($result = mysqli_query($sql_query, $search)) {
while ($row = mysqli_fetch_row($result)) {
$id = $row[0];
}
mysqli_free_result($result);
}
mysqli_close($sql_query);
return $id;
}
PHP код:
$_SESSION['id'] = GetUserID($Name);