Jump to content

Returning variables


johnslater

Recommended Posts

// Is there a user cookie set?
function cookie()
{
if (isset($_COOKIE["userlogin"]))
{
$cookie_acti = $_COOKIE["userlogin"];

$result = mysql_query("SELECT * FROM users WHERE activationid='$cookie_acti'");
while($row = mysql_fetch_array($result))
{
$cookie_username = $row['username'];
$cookie_fname = $row['fname'];
$cookie_lname = $row['lname'];

return $cookie_username;
return $cookie_fname;
return $cookie_lname;
}
}

else
{
$cookie_username = "Guest";
$cookie_fname = "Guest";
$cookie_lname = "";
}

} // End cookie function

cookie();

 

I have once used a different method to get 1 item from a database but i dont seem to be able to find it, if you could post another emthod that you think may fix the while loop then that would be great

Link to comment
Share on other sites

Is there anyway i can set up all of these varibles then just call them as normal like $cookie_username

 

I currently have this...

$cookie_fname = $cookie_fname=cookie();
$cookie_lname = $cookie_lname=cookie();
$cookie_username = $cookie_username=cookie();
$cookie_set = $cookie_set=cookie();

 

But for some reason the top one cancels out all of the others

Link to comment
Share on other sites

After slightly more testing and after putting this at the end of my function like you suggested it appear it only works with one value however i need to call several values from the same function.

 

return $cookie_username;

return $cookie_fname;

return $cookie_lname;

return $cookie_set;

 

Only the top one (username) is being used and no matter which value i try to call it always calls username

Link to comment
Share on other sites

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.