Jump to content

CMS Help


Rinn

Recommended Posts

I am trying to get a dynamic nav working and i am having a bit of trouble with the extraction of the information from the database.

 

the error is : Database query failed, Page Set error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

 

<?php
include 'includes/header.php';
include 'includes/database.php';
?>
<table id="structure">
<tr>
	<td id="navigation">
		<ul class="subjects">
		<?php
		// Subject Extract
		$subject_set = mysql_query("SELECT * FROM subjects",$connection);
		if(!$subject_set){
			die("Database query failed, Subject Set error");
		}

		while ($subject = mysql_fetch_array($subject_set)) {
				echo "<li>{$subject["menu_name"]}</li>";

		}
		// Subject end

		//Page Extract
		$page_set = mysql_query("SELECT * FROM pages WHERE subject_id = {$subject["id"]}",$connection);
		if(!$page_set){
			die("Database query failed, Page Set error ". mysql_error());
		}
		echo "<ul class=\"pages\">";
		while ($page = mysql_fetch_array($page_set)) {
			echo "<li>{$page["menu_name"]}</li>";
		}
		// Page End
		echo "</ul>";	
		?>
			</ul>
		</td>

		<td id="page">	
			<h2>Content Menu</h2>
			<p>Welcome to Opticalx CMS</p>

			<ul>
				<li><a href="content.php">Manage Website Content</a></li>
				<li><a href="new_user.php">Add Staff User</a></li>
				<li><a href="logout.php">Logout</a></li>
			</ul>
		</td>
	</tr>
</table>
<?php require ("includes/footer.php"); ?>

Link to comment
Share on other sites

Addressing an array element like above

 

$subject[id]

 

causes an additional operation for the php parser.  Without quotes around the key name, php will check to see if there is a constant with that name set, if it finds one, it will return the wrong value...if it doesn't then it will check to see if there is an element in the array with that key.

 

It's not wrong per se, but I wouldn't recommend it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.