1
corne
Wrong query??
  • 2005/3/3 9:56

  • corne

  • Just popping in

  • Posts: 24

  • Since: 2005/1/12


I have added the following to userinfo.php:

if(isset($HTTP_GET_VARS['usr'])){
  
//get UID from database
  
$uid_get_query 'SELECT uid FROM '.$xoopsDB->prefix('users').' WHERE uname='.$HTTP_GET_VARS['usr'];
  
$uid_get_result $xoopsDB->query($uid_get_query);
  while(
$uid_get $xoopsDB->fetchArray($uid_get_result))
  {
    
$uid $uid_get[0];
  }
}


It should be possible to gotohttp://www.yoursite.tld/userinfo.php?usr=uname
to get the profile...

But $uid stays empty (also when the user exists)
What is wrong with this query or what is wrong with the code??

I can't seem to find out why this doesn't work...

2
Mithrandir
Re: Wrong query??

Either use $xoopsDB->fetchArray() and $uid_get['uid']
or $xoopsDB->fetchRow() and $uid_get[0]

3
Dave_L
Re: Wrong query??
  • 2005/3/3 11:20

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Some other things:

$_GET should be used instead of $HTTP_GET_VARS.
The username should be sanitized prior to using it in a query.
The username needs to be in quotes.

$uid 0;
if (isset(
$_GET['usr'])){
   
$uname_q MyTextSanitizer::addSlashes($_GET['usr']);
   
$result $xoopsDB->query(
      
'SELECT uid FROM ' .$xoopsDB->prefix('users'). " WHERE uname='$uname_q'"
   
);
   
$row $xoopsDB->fetchArray($result);
   
$xoopsDB->freeRecordSet($result);
   
$uid = ($row !== false) ? $row['uid'] : 0;
}

Login

Who's Online

179 user(s) are online (81 user(s) are browsing Support Forums)


Members: 0


Guests: 179


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits