Jump to content

php "if" not working


desithugg

Recommended Posts

umm php "if" function isn't working again
my username is "desithugg" no capital
my table looks like this
________________
item | Owner | id
red  | desithugg | 1
________________
[code]<?php
mysql_connect("localhost", $my_sql_password, $my_sql_username) or
  die("Could not connect: " . mysql_error());
mysql_select_db("tpf");

$result = mysql_query("SELECT owner FROM pokeballs where id = '1'");
if (!$result) {
  echo 'Could not run query: ' . mysql_error();
  exit;
}
$row = mysql_fetch_row($result);

$owner = $row[0];
?>[/code]
and btw. in the next peice the $user_currently_loged variables outputs my username
[code]
<?PHP
if ($owner != "$user_currently_loged"){
echo "<center>Sorry the item you specified to use does not belong to you.";
exit();
}
?>[/code]
Link to comment
Share on other sites

Try this please ok.

[code]
<?php

mysql_connect("localhost", $my_sql_password, $my_sql_username) or
  die("Could not connect: " . mysql_error());
mysql_select_db("tpf");

$query ="SELECT owner FROM pokeballs where id = '1' ";
$result=mysql_query($query) or die(mysql_problam());

if (!$result) {
  echo 'Could not run query: ' . mysql_error();
  exit;
}
while($row=mysql_fetch_assoc($result)){

$owner = $row[0];

}
?>

[/code]

[code]
<?PHP

mysql_connect("localhost", $my_sql_password, $my_sql_username) or
   die("Could not connect: " . mysql_error());
mysql_select_db("tpf");

$query ="SELECT * FROM pokeballs where id = '1' ";
$result=mysql_query($query)or die(mysql_problam());

while($row=mysql_fetch_assoc($result)){

$owner = $row[0];


if (! $owner) {
echo "<center>Sorry the item you specified to use does not belong to you.";
exit();
}
}
?>
[/code]
Link to comment
Share on other sites

You might also want to add "or die (mysql_error());" to your query to make sure it is executing correctly and to get an error if not:

[code=php]
$result = mysql_query("SELECT owner FROM pokeballs where id = '1'") or die (mysql_error());
[/code]
Link to comment
Share on other sites

iv found the error for some reson
the include is not working so it compares the owner with "" a blank username im not sure why
<?php
$reqlevel = 1;
include("membersonly.inc.php");
?>

and its not working no matter which file i try to include
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.