/    Sign up×
Community /Pin to ProfileBookmark

problems with query and showing

Yea well nothing is shown when i use this

[code=php]
<?php
include(“includes/config.php”);
$sql = mysql_fetch_array(mysql_query(“Select * From player_account Where account = ‘$acc'”)) or die(mysql_error());
echo ”
<table border=”2″ align=”center”>
<tr> <th>Account information</th>
</tr> <tr>
<td>Email address:</td><td>$sql->e-mail</td>
</tr> <tr>
<td>Created:</td><td>$sql->created</td>
</tr> <tr>
<td>Last login:</td><td>$sql->lastlogin</td>
</tr>
</table><br>
“;
if($sql->banned <= 1){
$sql2 = mysql_fetch_array(mysql_query(“Select * from player_banned Where account = ‘$acc'”)) or die(mysql_error());
echo ”
<table border=”2″ align=”center”>
<tr><th>Criminal record</th>
</tr> <tr>
<th>Date:</th><th>Reason:</th><tr>View</th>
</tr>”;
$i = 0;
foreach($sql2 as $i){
$i++;
echo ”
<tr>
<td>$sql2->banned_time</td><td>$sql2->banned_res</td><td><a href=”account_home.php?subtopic=viewban&char=$sql2->name”>$sql2->name</a></td>
</tr>”;
}

}
?>
[/code]

if i remove or die(mysql_error()); then the table will be shown and i get theses errors

[code=php]
Notice: Trying to get property of non-object in C:webserverwwwkattenaccount_home.php on line 40

Notice: Use of undefined constant mail – assumed ‘mail’ in C:webserverwwwkattenaccount_home.php on line 40

Notice: Trying to get property of non-object in C:webserverwwwkattenaccount_home.php on line 42

Notice: Trying to get property of non-object in C:webserverwwwkattenaccount_home.php on line 44
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@SheldonFeb 01.2006 — Whats in "config.php"?

Where are you setting $acc?

Why is your path in the error

"C:webserverwwwkattenaccount_home.php" where are the / to seperate the folders?

Try just one query first?
[code=php]

<?php
include("includes/config.php");
$s = "Select * From player_account Where account = '$acc'";
$r = mysql_query($s);

while($sql = mysql_fetch_assoc($r)){

?>
<table border="2" align="center">
<tr> <th>Account information</th>
</tr> <tr>
<td>Email address:</td><td><?php echo($sql['email']); ?></td>
</tr> <tr>
<td>Created:</td><td><?php echo($sql['created']); ?></td>
</tr> <tr>
<td>Last login:</td><td><?php echo($sql['login']); ?></td>
</tr>
</table><br>
<?php
if($sql['banned'] <= 1){
// do second query
}else{
//there was an error!!!!
}

?>[/code]
Copy linkTweet thisAlerts:
@chazzyFeb 01.2006 —  Notice: Trying to get property of non-object in C:webserverwwwkattenaccount_home.php on line 40

Notice: Trying to get property of non-object in C:webserverwwwkattenaccount_home.php on line 42

Notice: Trying to get property of non-object in C:webserverwwwkattenaccount_home.php on line 44 [/quote]


These 3 warnings are because you're using $varname->attribute but $varname is an array, and to call its elements you need to use $varname['attribute'].

Remember, even though they're very similar in php, arrays !== objects

The fact that you got output means that this is a syntax error:

[code=php]
$sql2 = mysql_fetch_array(mysql_query("Select * from player_banned Where account = '$acc'")) or die(mysql_error());
[/code]

and should be split up. basically you're saying fetch the array of die and that's not good (even if die does kill the script..)

and the last warning is

Notice: Use of undefined constant mail - assumed 'mail' in C:webserverwwwkattenaccount_home.php on line 40
[/quote]

should go away when you switch to arrays. this isn't valid:

$var->my-name because it's looking for the attribute "my" of object "$var" and wants to subtract the constant "name" and that's whats happening when you have "e-mail"
×

Success!

Help @katten spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...