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(); } ?> Quote Link to comment 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 Quote Link to comment 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' "); Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Bradley99 Posted January 30, 2011 Author Share Posted January 30, 2011 Still not working.....Daym! Quote Link to comment Share on other sites More sharing options...
blew Posted January 30, 2011 Share Posted January 30, 2011 man, post the error given... Quote Link to comment 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. Quote Link to comment 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!!! Quote Link to comment 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? Quote Link to comment 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(); ?> Quote Link to comment 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.