j05hr Posted September 22, 2009 Share Posted September 22, 2009 I'm following a tutorial and i get an error, I copy and paste the example code but I think they must of edited the error without saying why or where. It's probably a really simple mistake that I don't notice because I'm only starting to learn. Here is the error message: "Database query failed: Unknown column 'position' in 'order clause'" And the code... functions.php <?php // This file is the place to store all basic functions function confirm_query($result_set) { if (!$result_set) { die("Database query failed: " . mysql_error()); } } function get_all_subjects() { global $connection; $query = "SELECT * FROM subjects ORDER BY position ASC"; $subject_set = mysql_query($query, $connection); confirm_query($subject_set); return $subject_set; } function get_pages_for_subject($subject_id) { global $connection; $query = "SELECT * FROM pages WHERE subject_id = {$subject_id} ORDER BY position ASC"; $page_set = mysql_query($query, $connection); confirm_query($page_set); return $page_set; } ?> content.php <?php require_once("includes/connection.php")?> <?php require_once("includes/functions.php")?> <?php include("includes/header.php")?> <table id="structure"> <tr> <td id="navigation"> <ul class="subjects"> <?php $subject_set = get_all_subjects(); while($subject = mysql_fetch_array($subject_set)) { echo "<li>{$subject["menu_name"]}</li>"; $page_set = get_pages_for_subject($subject["id"]); echo "<ul class=\"pages\">"; while ($page = mysql_fetch_array($page_set)) { echo "<li>{$page["menu_name"]}</li>"; } echo "</ul>"; } ?> </ul> </td> <td id="page"> <h2>Content Area</h2> </td> </tr> </table> <?php require("includes/footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
Bricktop Posted September 22, 2009 Share Posted September 22, 2009 Hi j05hr, The error is in your functions.php code. In particular, these two queries: $query = "SELECT * FROM subjects ORDER BY position ASC"; Basically, the error is saying that the "positions" column does not exist in the database. Hope this helps. Quote Link to comment Share on other sites More sharing options...
j05hr Posted September 22, 2009 Author Share Posted September 22, 2009 Ah thanks, I was going mad looking over that code trying to work out what little mistake I had. I went to check my database after what you said and it was that I mistyped position in my database. Thanks for the help. 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.