Snaxpac Posted May 22, 2008 Share Posted May 22, 2008 Hey guys, I'm trying to pull an int($id) out of my database, however, whenever I output the result it says 'array'... What am I doing wrong? Is it that I'm storing it into the variable wrong? function getHome($session_id, $email, $encryptedPassword) { if (! isset($session_id) || ! isset($email) || ! isset($encryptedPassword)){ return "Login Error: You need to enter a vailid Email and Password! Retuen <a href = index.php>Home</a>"; } else { $connection = @ mysql_connect(HOST, USER, PASSWORD) or die("Could not connect"); mysql_select_db(DATABASE, $connection) or showerror(); $salt = substr($email, 0, 2); $enc_session_id = crypt($session_id, $salt); $query = "SELECT member_id FROM as2_members" . " WHERE email = '$email'" . " AND password = '$encryptedPassword'" . " AND session_id = '$enc_session_id'" $result = mysql_query($query, $connection) or showerror(); $id = mysql_fetch_array($result); mysql_close($connection) or showerror(); return "Logging In... " . $id; } } Any help would be great thanks =). Quote Link to comment https://forums.phpfreaks.com/topic/106728-mysql-help/ Share on other sites More sharing options...
sasa Posted May 22, 2008 Share Posted May 22, 2008 change last linr to return "Logging In... " . $id[0]; Quote Link to comment https://forums.phpfreaks.com/topic/106728-mysql-help/#findComment-547121 Share on other sites More sharing options...
Snaxpac Posted May 22, 2008 Author Share Posted May 22, 2008 Thanks for the reply =) When pulling the int out of the database it is making it an array? How do i get it to actually to display the int value? When I do that its just showing what is at position 0 which is nothing? Quote Link to comment https://forums.phpfreaks.com/topic/106728-mysql-help/#findComment-547125 Share on other sites More sharing options...
sasa Posted May 22, 2008 Share Posted May 22, 2008 are you shure that your query return any result? for debuging insert before return echo 'query returns ',mysql_num_rows($results), ' row'; Quote Link to comment https://forums.phpfreaks.com/topic/106728-mysql-help/#findComment-547129 Share on other sites More sharing options...
Snaxpac Posted May 22, 2008 Author Share Posted May 22, 2008 You were right, thanks for the help =) Quote Link to comment https://forums.phpfreaks.com/topic/106728-mysql-help/#findComment-547132 Share on other sites More sharing options...
sasa Posted May 22, 2008 Share Posted May 22, 2008 $session_id maybe cause trouble Quote Link to comment https://forums.phpfreaks.com/topic/106728-mysql-help/#findComment-547135 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.