Jump to content

Select FROM WHERE Help


Bradley99

Recommended Posts

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
Share on other sites

$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
Share on other sites

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
Share on other sites

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
Share on other sites

  • 2 weeks later...

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.