dual_alliance Posted September 21, 2006 Share Posted September 21, 2006 I get this error:[quote]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in myreports.php on line 45[/quote]I think it could be because of the way l have set out my PHP code. The code l have near line 45 is:[code=php:0]<?php // Read information from MySQL database $result = mysql_query("SELECT * FROM 'bug_report' WHERE '$username' = bug.submitter"); while ($row = mysql_fetch_array($result)){ <-- Line 45 ?> <tr> <td><?php echo $rows['bug.id']; ?></td> <td><?php echo $rows['bug.date']; ?></td> <td><?php echo $rows['bug.title']; ?></td> <td><?php echo $rows['bug.description']; ?></td> <td><?php echo $rows['bug.urgency']; ?></td> </tr> <?php } ?>[/code]Your help is greatly appreciated,Thanks Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 22, 2006 Share Posted September 22, 2006 You are using the wrong types of quotes, in your query, they should be backticks. And I don't think you should have a dollar sign on the "username" field. Change those lines to:[code]<?php$query = "SELECT * FROM `bug_report` WHERE `username` = bug.submitter";$result = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error());?>[/code]Using the "or die" clause will let you see any sytax errors that you might not see otherwise.Ken Quote Link to comment Share on other sites More sharing options...
dual_alliance Posted September 22, 2006 Author Share Posted September 22, 2006 Thankyou very much kenrbnsn for your speedy reply and help. It works perfectly now, l just edited it so it is now:[code=php:0] <?php // Read information from MySQL database $query = "SELECT `bug.id`, `bug.date`, `bug.title`, `bug.description`, `bug.urgency` FROM `bug_report` WHERE `bug.submitter` = '$username' "; $result = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error()); while ($row = mysql_fetch_array($result)){ ?> <tr> <td><?php echo $row['bug.id']; ?></td> <td><?php echo $row['bug.date']; ?></td> <td><?php echo $row['bug.title']; ?></td> <td><?php echo $row['bug.description']; ?></td> <td><?php echo $row['bug.urgency']; ?></td> </tr> <?php } ?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.