0

I dont know why this code will not show any data from the mysql.........................

$query = "SELECT * FROM g_attack WHERE winner ='$username' ORDER BY created ASC LIMIT 10"; 
$row = mysql_query($query) or die("Could not connect to db"); 
while ( $result = mysql_fetch_assoc($row)) { 
$created = $row['created'];
$looser = $row['looser'];
$stolengold = $row['stolengold'];
 
echo '<tr>'; 
echo '<td>'.$created.'</td><td>You won over <b>'.$looser.'</b> and stole <b>'.$stolengold.'</b></td>';
echo '</tr>';

}

the database is connected, it is data in the database, but it just dont wanna get any info from it....

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Sorcher
0

you did a silly mistake in your code....
check your line 4,5,6
replace it with

$created = $result['created'];
$looser = $result['looser'];
$stolengold = $result['stolengold'];

So the complete code will be....

$query = "SELECT * FROM g_attack WHERE winner ='$username' ORDER BY created ASC LIMIT 10"; 
$row = mysql_query($query) or die("Could not connect to db"); 
while ( $result = mysql_fetch_assoc($row)) { 
$created = $result['created'];
$looser = $result['looser'];
$stolengold = $result['stolengold'];
 
echo '<tr>'; 
echo '<td>'.$created.'</td><td>You won over <b>'.$looser.'</b> and stole <b>'.$stolengold.'</b></td>';
echo '</tr>';
 
}

PS-If your problem is solved mark the thread as solved

0

yeah i saw it like 1 hour after i posted it, but really, thanks for help. When you're "wired-in" its easy to write quick and deep but easier to do small mistakes.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.