The majority of forums are now only available as archives, which means posting/editing is disabled.
The Anything and Everything forum is still open.
Time: 2013-05-18, 10:19am
Please
login or
register to post a reply.
|
|
| Subject: Whats wrong with this please · Posted: 2004-12-01, 02:31am |
|
|
|
Rank: ? (53)
Member #: 16444
|
The result im getting is "Query is Empty"
any ideas pls?
(there is deffinately values in the database that are correct.)
Code:
<?php
-
- include ('check_login.php');
-
-
- $name = $_SESSION['username'];
-
- $query = mysql_query("SELECT USERNAME, PERCENT FROM burnleycollege_mod1_results WHERE CANDIDATE_USERNAME='$name'");
- $result = mysql_query($query) or die(mysql_error());
-
- echo "<table>";
-
- while ($row = mysql_fetch_array($result))
- {
- $username = $row['username'];
- $percent = $row['percent'];
-
-
-
-
-
-
- echo "<tr><td>$username</td>
- <td>$percent</td></tr>";
-
-
- }
- echo "</table>";
- ?>
» Post edited 2004-12-01, 02:32am by Elliott.
|
|
|
| Subject: Re: Whats wrong with this please · Posted: 2004-12-01, 06:40am |
|
|
|
Rank: ? (900)
Member #: 3
|
Code:
<?
- $query = mysql_query("SELECT USERNAME, PERCENT FROM burnleycollege_mod1_results WHERE CANDIDATE_USERNAME='".$name."'");
-
- ?>
line #9 reads: $result = mysql_query($query) or die(mysql_error());
you could just do like this:
if (!$query) die('query failed: '.mysql_error());
then go on to
while ($row = mysql_fetch_array($query))
» Post edited 2004-12-01, 06:46am by bs0d.
|
|
|
| Subject: Re: Whats wrong with this please · Posted: 2004-12-01, 01:24pm |
|
|
|
Rank: ? (768)
Member #: 11085
|
ur code should be (for maximum optimization)
Code:
<?php
- include ('check_login.php');
- $name = $_SESSION['username'];
- $query = mysql_query("SELECT USERNAME, PERCENT FROM burnleycollege_mod1_results WHERE CANDIDATE_USERNAME='".$name."'") or die(mysql_error());
- ?>
- <table>
- <?php
- while ($row = mysql_fetch_array($query)){
- ?>
- <tr><td><?=$row['username']?></td>
- <td><?=$row['percent']?></td></tr>
- <?php
- }
- ?>
- </table>
your problem was you were trying to call a query using the result of a query (qhih is just a pointer) whcih cannot work.
|
Pages: 1
Please
login or
register to post a reply.