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
https://forums.phpfreaks.com/topic/16034-php-if-not-working/
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
https://forums.phpfreaks.com/topic/16034-php-if-not-working/#findComment-65965
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.