Jump to content

[SOLVED] PHP error code


j05hr

Recommended Posts

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"); ?>

Link to comment
https://forums.phpfreaks.com/topic/175111-solved-php-error-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.