Jump to content

small query, an easy one


scottybwoy

Recommended Posts

I have this code here :
[code]
<?php

$domain_user = explode("\\", $_SERVER['LOGON_USER']);
$user = $domain_user[1];
echo $user;

$AUTH_DB_NAME = 'mri_sql';
$AUTH_DB_TBL    = 'users';

mssql_connect("localhost,1433", "user", "pass", "") or
die("Failed Connection");
mssql_select_db("$AUTH_DB_NAME") or
die ("cannot connect to database");

$result = mssql_query("SELECT USER_ID FROM users WHERE uNAME = '" . $user . "' AND ACTIVE = '1'");

echo $result;

?>
[/code]

And I get this result :

technicalResource id #2

Shouldn't I get :

technical3

technical being my username and 3 being my ID
Link to comment
https://forums.phpfreaks.com/topic/18633-small-query-an-easy-one/
Share on other sites

maybe, that didn't return anything except technical.  How am I supposed to know the row number ($row['yourow']) when what I am after is the user ID from the row containing the user name.

Tried both and they return the same, only the user name

Thanks though
OK this is my code now :
[code]
<?php

$domain_user = explode("\\", $_SERVER['LOGON_USER']);
$user = $domain_user[1] . "<br />";
echo $user;

$AUTH_DB_NAME = 'mri_sql';
$AUTH_DB_TBL    = 'users';

mssql_connect("localhost", "1433", "user", "pass") or
die("cannot connect");
mssql_select_db("$AUTH_DB_NAME") or
die ("cannot connect to database");

$query = "SELECT * FROM users where uName = '$user' AND active = 1";
$query = stripslashes($query);
$result = mssql_query($query);
while($row = mssql_fetch_assoc($result)){
if ($row[uName] == $user)
$idImLookingFor = $row['user_id'];
}

print_r($row);
?>
[/code]

Which output's :

technical

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.