PDA

View Full Version : [help] PHP Errors



coolchris322
11-10-2010, 04:53 PM
Ok, first error. this

session_start();
$username = $_SESSION['myusername'];
$query = mysql_query("SELECT * FROM `community` WHERE username='$username'");
$row = mysql_fetch_array($query);
... blah blah blah ...
if($row['ban'] = "1")
echo '<td><a href=\'?change=appealban\' target=\'_self\'>Appeal Ban</a></td>';now, it echo's appeal ban even when ban = 0.

Second issue,

session_start();
$loggeduser = $_SESSION['myusername'];
include 'config.php';
$username = $_GET['name'];
$query = mysql_query("SELECT * FROM `community` WHERE username='$username'");
$row = mysql_fetch_array($query);
$query2 = mysql_query("SELECT * FROM `community` WHERE username='$loggeduser'");
$row2 = mysql_fetch_array($query2);
... blah blah blah ...
if ($loggeduser = $row['habboname']) {
echo "<a href='editprofile.php'>Edit Your Profile</a>";
}
if ($row2['rank'] = "Administrator") {
echo "<a href='edituser.php?name=".urlencode(htmlspecialchars($row['username'], ENT_QUOTES))."'>Edit User</a>";
}This 1. shows edit profile when you logout and clear your cache, but only on your profile o.O
2. echo's Edit User even when your logged out, logged in with non-admin etc.

Any help please.

coolchris322
11-10-2010, 05:26 PM
Anyone here to help :(

LMS16
11-10-2010, 08:31 PM
In some cases, u need to use "==" instead of "=" that will be your problems I suspend :)

Lew.

Johno
11-10-2010, 08:52 PM
You use "=" in order to set (assign) a value to variables, "==" in order to compare both sides.

http://www.php.net/manual/en/language.operators.comparison.php

As Lewiie says, seems to be the only problem.

Irrorate
12-10-2010, 02:45 PM
Just to reiterate the above, one = sign assigns a variable, two = signs compares a variable.

BTW, if you are using single quotes you don't need to escape your HTML:


session_start();
$username = $_SESSION['myusername'];
$query = mysql_query("SELECT * FROM `community` WHERE username='$username'");
$row = mysql_fetch_array($query);
... blah blah blah ...
if($row['ban'] = "1")
echo '<td><a href="?change=appealban" target="_self">Appeal Ban</a></td>';

coolchris322
12-10-2010, 06:56 PM
I know == does that, but that broke too xD.

anyhow, i did a mysql dump file and checked against values and counts to fix it :/

Want to hide these adverts? Register an account for free!