jarv Posted December 4, 2010 Share Posted December 4, 2010 here is my code: $query2 = "SELECT * FROM members_copy WHERE RSUSER = ".$_SESSION["rsUser"].""; $result2 = mysql_query($query2); $UserID = $result2['USERID']; echo $UserID; When I echo out UserID it doesn't show a number?! Please help?! Link to comment https://forums.phpfreaks.com/topic/220684-passing-through-userid/ Share on other sites More sharing options...
Pikachu2000 Posted December 4, 2010 Share Posted December 4, 2010 $result2 doesn't hold a value, it holds a query result resource. You need to get the values from that with mysql_fetch_assoc or similar. Link to comment https://forums.phpfreaks.com/topic/220684-passing-through-userid/#findComment-1143039 Share on other sites More sharing options...
jarv Posted December 4, 2010 Author Share Posted December 4, 2010 thanks, now I get: <b>Warning</b>: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in <b>D:\mypubspace.com\wwwroot\main.php Link to comment https://forums.phpfreaks.com/topic/220684-passing-through-userid/#findComment-1143043 Share on other sites More sharing options...
jarv Posted December 5, 2010 Author Share Posted December 5, 2010 please help Link to comment https://forums.phpfreaks.com/topic/220684-passing-through-userid/#findComment-1143069 Share on other sites More sharing options...
Pikachu2000 Posted December 5, 2010 Share Posted December 5, 2010 Post your newly revised code. Link to comment https://forums.phpfreaks.com/topic/220684-passing-through-userid/#findComment-1143076 Share on other sites More sharing options...
jarv Posted December 5, 2010 Author Share Posted December 5, 2010 $data = "SELECT * FROM members_copy WHERE RSUSER = ".$_SESSION["rsUser"].""; $info = mysql_fetch_array( $data ); echo $info['USERID']; Link to comment https://forums.phpfreaks.com/topic/220684-passing-through-userid/#findComment-1143079 Share on other sites More sharing options...
PFMaBiSmAd Posted December 5, 2010 Share Posted December 5, 2010 The following link is a basic php/mysql tutorial that shows how to execute a select query and fetch the results from the query - http://w3schools.com/php/php_mysql_select.asp Link to comment https://forums.phpfreaks.com/topic/220684-passing-through-userid/#findComment-1143086 Share on other sites More sharing options...
jarv Posted December 5, 2010 Author Share Posted December 5, 2010 Please help?! is this correct? $data = "SELECT * FROM members_copy WHERE RSUSER = ".$_SESSION["rsUser"]; $info = mysql_fetch_array($data); Link to comment https://forums.phpfreaks.com/topic/220684-passing-through-userid/#findComment-1143386 Share on other sites More sharing options...
jarv Posted December 5, 2010 Author Share Posted December 5, 2010 I basically want to get the USERID of the person logged in Link to comment https://forums.phpfreaks.com/topic/220684-passing-through-userid/#findComment-1143399 Share on other sites More sharing options...
jarv Posted December 5, 2010 Author Share Posted December 5, 2010 here is my login functions: function checkPass($login, $password) { /* Password checking function: This is a simple function that takes the $login name and $password that a user submits in a form and checks that a row exists in the database where: the value of the 'login' column is the same as the value in $login and the value of the 'password' column is the same as the value in $password If exactly one row is returned, then that row of data is returned. If no row is found, the function returns 'false'. */ global $link; $query="SELECT rsUser, rsPass FROM members WHERE rsUser='$login' and rsPass='$password'"; $result=mysql_query($query, $link) or die("checkPass fatal error: ".mysql_error()); // Check exactly one row is found: if(mysql_num_rows($result)==1) { $row=mysql_fetch_array($result); return $row; } //Bad Login: return false; } // end func checkPass($login, $password) /******************************************************\ * Function Name : cleanMemberSession($login, $pass) * * Task : populate a session variable * * Arguments : string $login, string $pass taken from users table in db. * * Returns : none * \******************************************************/ function cleanMemberSession($login, $password) { /* Member session initialization function: This function initializes 3 session variables: $login, $password and $loggedIn. $login and $password are used on member pages (where you could allow the user to change their password for example). $loggedIn is a simple boolean variable which indicates whether or not the user is currently logged in. */ $_SESSION["rsUser"]=$login; $_SESSION["rsPass"]=$password; $_SESSION["loggedIn"]=true; } // end func cleanMemberSession($login, $pass) Link to comment https://forums.phpfreaks.com/topic/220684-passing-through-userid/#findComment-1143401 Share on other sites More sharing options...
jarv Posted December 6, 2010 Author Share Posted December 6, 2010 Please help? Link to comment https://forums.phpfreaks.com/topic/220684-passing-through-userid/#findComment-1143419 Share on other sites More sharing options...
BlueSkyIS Posted December 6, 2010 Share Posted December 6, 2010 Please help?! is this correct? $data = "SELECT * FROM members_copy WHERE RSUSER = ".$_SESSION["rsUser"]; $info = mysql_fetch_array($data); what happens when you TRY IT? Link to comment https://forums.phpfreaks.com/topic/220684-passing-through-userid/#findComment-1143441 Share on other sites More sharing options...
devilinc Posted December 6, 2010 Share Posted December 6, 2010 i think the session variable stores alphanumeric data... CHANGE::: $data = "SELECT * FROM members_copy WHERE RSUSER = ".$_SESSION["rsUser"]; $info = mysql_fetch_array($data); DO THIS::: //note that i have added quites befire and after your session variable... $data = "SELECT * FROM members_copy WHERE RSUSER = ' ".$_SESSION["rsUser"]." ' "; $info = mysql_fetch_array($data); //say if user_id is the user id column in your table then echo $info['usr_id']; Link to comment https://forums.phpfreaks.com/topic/220684-passing-through-userid/#findComment-1143548 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.