Jump to content

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.