SirChick Posted August 21, 2007 Share Posted August 21, 2007 I have two queries searching for UserID on two tables... but it wont echo my second query.. the first one works how ever even though they are structured the same. This is what i have: // Get the user's info from the database by putting // the user id stored in the session into the WHERE clause $GetUserID = mysql_query("SELECT * FROM userregistration WHERE UserID='{$_SESSION['Current_User']}'"); // Fetch the row from the database if (!($row = mysql_fetch_assoc($GetUserID))) { echo "User not found!"; exit; echo mysql_error(); } $GetHouseInfo = mysql_query("SELECT * FROM houses WHERE UserID='{$_SESSION['Current_User']}'"); // Fetch the row from the database if (!($houserow = mysql_fetch_assoc($GetHouseInfo))) { echo "User not found!"; exit; } $UserID = $row["UserID"]; $HouseType = $houserow["HouseID"]; Echo $UserID Echo $HouseType The result is: UserID : 23 House : Anyone know why? Quote Link to comment https://forums.phpfreaks.com/topic/65958-solved-echo-wont-work-on-second-query/ Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 $GetHouseInfo = mysql_query("SELECT * FROM houses WHERE UserID='{$_SESSION['Current_User']}'") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/65958-solved-echo-wont-work-on-second-query/#findComment-329768 Share on other sites More sharing options...
SirChick Posted August 21, 2007 Author Share Posted August 21, 2007 Ok just tried it and still got : UserID : 23 House : Quote Link to comment https://forums.phpfreaks.com/topic/65958-solved-echo-wont-work-on-second-query/#findComment-329773 Share on other sites More sharing options...
pranav_kavi Posted August 21, 2007 Share Posted August 21, 2007 try printing out the query before executing it. Is the column name right $HouseType = $houserow["HouseID"]; Quote Link to comment https://forums.phpfreaks.com/topic/65958-solved-echo-wont-work-on-second-query/#findComment-329776 Share on other sites More sharing options...
SirChick Posted August 21, 2007 Author Share Posted August 21, 2007 HouseID int(11) Table name : houses i just copied and pasted. they are deffinatly correctly. i tried to print it and it came out blank Quote Link to comment https://forums.phpfreaks.com/topic/65958-solved-echo-wont-work-on-second-query/#findComment-329781 Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 do print_r($houserow); below the echo Quote Link to comment https://forums.phpfreaks.com/topic/65958-solved-echo-wont-work-on-second-query/#findComment-329782 Share on other sites More sharing options...
SirChick Posted August 21, 2007 Author Share Posted August 21, 2007 11Array ( [HouseID] => 1 [CityID] => 1 [HouseType] => Cottage [userID] => 1 ) print ^ Quote Link to comment https://forums.phpfreaks.com/topic/65958-solved-echo-wont-work-on-second-query/#findComment-329783 Share on other sites More sharing options...
pranav_kavi Posted August 21, 2007 Share Posted August 21, 2007 pls post how the problem was solved.it wud help others who wud come across similar issues. Quote Link to comment https://forums.phpfreaks.com/topic/65958-solved-echo-wont-work-on-second-query/#findComment-329831 Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 the problem is possible the down to the error not reported Echo $UserID Echo $HouseType notice the lack of ; Quote Link to comment https://forums.phpfreaks.com/topic/65958-solved-echo-wont-work-on-second-query/#findComment-329834 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.