Hi folks,
I've got an error somewhere in my sql syntax and not sure where I'm going wrong ... any ideas?
I'm trying to put onto the page;
Home
This is a test
(and then any other content that might be associated with the page)
I know the first bit of PHP works, but when I tried putting in the second bit it just stopped working and I can't figure out why
Thanks
Database structures are:
I've got an error somewhere in my sql syntax and not sure where I'm going wrong ... any ideas?
I'm trying to put onto the page;
Home
This is a test
(and then any other content that might be associated with the page)
I know the first bit of PHP works, but when I tried putting in the second bit it just stopped working and I can't figure out why

Thanks

SQL Error
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 2
Code:
<?php
$page = $_GET['page'];
if($page < 1)
$page = 1;
$sqlquery = @mysql_query("SELECT PageName FROM tblPages WHERE PageID='$page'");
if(!$sqlquery)
exit('<p>Error fetching villa details: ' . mysql_error() . '</p>');
$sqlquery = mysql_fetch_array($sqlquery);
$PageName = $sqlquery['PageName'];
$PageName = htmlspecialchars($sqlquery['PageName']);
?>
<h1><?php echo $PageName; ?></h1>
<?php
$sqlquery2 = @mysql_query("SELECT SectionID, PageID, PageName, SectionOrder, SectionContent FROM tblSections WHERE
PageID='$page' ORDER BY SectionOrder'");
if(!$sqlquery2)
exit('<p>Error retrieving sections from database!<br />' . 'Error: ' . mysql_error() . '</p>');
while($section = mysql_fetch_array($sqlquery2))
{
$SectionContent = $section['SectionContent'];
$SectionContent = htmlspecialchars($section['SectionContent']);
echo $SectionContent;
}
?>
Database structures are:
tblPages
| PageID | MenuOrder | MenuItem | PageName | PageLink |
| -- 1 --- | ----- 1 ---- | ---- 1 ---- | -- Home -- | - NULL - |
tblSections
| SectionID | PageID | PageName | SectionOrder | SectionContent |
| ---- 1 ---- | --- 1 -- | -- Home - | ------ 1 ------ | This is a test |
Last edited: