Bradley99 Posted January 29, 2011 Share Posted January 29, 2011 Hi guys, I'm trying to do make this code so that IF a user owns a property (in this code a bulletfactory) then the BF CP Shows up... Here's the code so far..... <?php session_start(); include_once"includes/db_connect.php"; include_once"includes/functions.php"; logincheck(); $username=$_SESSION['username']; $query=mysql_query("SELECT * FROM users WHERE username='$username'"); $fetch=mysql_fetch_object($query); $query_bf=mysql_query("SELECT * FROM bf WHERE location='England, Japan, Colombia, USA, Russia, Italy, Turkey'"); $fetch_bf=mysql_fetch_object($query_bf); if (strtolower($fetch_bf->owner) == (strtolower($fetch->username))){ require_once"bulletCP.php"; exit(); } ?> Link to comment https://forums.phpfreaks.com/topic/226009-select-from-where-help/ Share on other sites More sharing options...
mike12255 Posted January 29, 2011 Share Posted January 29, 2011 $query=mysql_query("SELECT * FROM users WHERE username='$username'") or die (mysql_error()); lets see what error it gives you, if any. Also do you understand that in location the text has to exactly look like this spaces and all or it will return 0: England, Japan, Colombia, USA, Russia, Italy, Turkey Link to comment https://forums.phpfreaks.com/topic/226009-select-from-where-help/#findComment-1166785 Share on other sites More sharing options...
lazylodr Posted January 29, 2011 Share Posted January 29, 2011 Did you mean: $query_bf=mysql_query (" SELECT * FROM bf WHERE location IN ('England', 'Japan', 'Colombia', 'USA', 'Russia', 'Italy', 'Turkey') AND owner = '$username' "); Link to comment https://forums.phpfreaks.com/topic/226009-select-from-where-help/#findComment-1166848 Share on other sites More sharing options...
Bradley99 Posted January 30, 2011 Author Share Posted January 30, 2011 Neither of them helped sorry, maybe i should try - $query_bf=mysql_query (" SELECT * FROM bf WHERE location IN ('England', 'Japan', 'Colombia', 'USA', 'Russia', 'Italy', 'Turkey') AND owner = '$username' "); if (strtolower($fetch_bf->owner) == (strtolower($fetch->username))){ echo "The BF CP Code here? Or not? Link to comment https://forums.phpfreaks.com/topic/226009-select-from-where-help/#findComment-1167392 Share on other sites More sharing options...
Bradley99 Posted January 30, 2011 Author Share Posted January 30, 2011 Still not working.....Daym! Link to comment https://forums.phpfreaks.com/topic/226009-select-from-where-help/#findComment-1167399 Share on other sites More sharing options...
blew Posted January 30, 2011 Share Posted January 30, 2011 man, post the error given... Link to comment https://forums.phpfreaks.com/topic/226009-select-from-where-help/#findComment-1167453 Share on other sites More sharing options...
btherl Posted January 31, 2011 Share Posted January 31, 2011 Can you try this: $query_bf=mysql_query (" SELECT * FROM bf WHERE location IN ('England', 'Japan', 'Colombia', 'USA', 'Russia', 'Italy', 'Turkey') AND owner = '$username' ") or die("Query failure: " . mysql_error()); $num_rows = mysql_num_rows($query_bf); die("We got $num_rows results"); If it says "We got 0 results", then your query is not matching anything. If it says 1 or more, then your fetching code should work. Link to comment https://forums.phpfreaks.com/topic/226009-select-from-where-help/#findComment-1167563 Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Author Share Posted February 8, 2011 'We got 7 Results' But fetching the bfCP isnt working!!! Link to comment https://forums.phpfreaks.com/topic/226009-select-from-where-help/#findComment-1171312 Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Author Share Posted February 8, 2011 Okay, so with that code i got it requiring the BF CP Page Finally!! I tried Writing the same code for the Airport CP underneath but it doesn't post that one? OR isit the case i can't require 2 pages? Link to comment https://forums.phpfreaks.com/topic/226009-select-from-where-help/#findComment-1171316 Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Author Share Posted February 8, 2011 This is all fixed now, I'll post the working code and mark as Solved !! Thanks <?php session_start(); include_once"includes/db_connect.php"; include_once"includes/functions.php"; logincheck(); $username=$_SESSION['username']; $query=mysql_query("SELECT * FROM users WHERE username='$username'") or die (mysql_error()); $fetch=mysql_fetch_object($query); $query_bf=mysql_query (" SELECT * FROM bf WHERE location IN ('England', 'Japan', 'Colombia', 'USA', 'Russia', 'Italy', 'Turkey') AND owner = '$username' ") or die("Query failure: " . mysql_error()); $num_rows = mysql_num_rows($query_bf); require_once"bulletCP.php"; $query_airport=mysql_query (" SELECT * FROM airport WHERE location IN ('England', 'Japan', 'Colombia', 'USA', 'Russia', 'Italy', 'Turkey') AND owner = '$username' ") or die("Query failure: " . mysql_error()); $num_rows = mysql_num_rows($query_airport); require_once"airportCP.php"; exit(); ?> Link to comment https://forums.phpfreaks.com/topic/226009-select-from-where-help/#findComment-1171325 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.