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
https://forums.phpfreaks.com/topic/62761-cms-help/
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
https://forums.phpfreaks.com/topic/62761-cms-help/#findComment-312501
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.