View Single Post
  #1 (permalink)  
Old 04-18-06, 04:14 AM
gigafare gigafare is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
MySQL Syntax error

Problem: A syntax error occurs when creating a page where the link is not shown in the menu. It's an MySQL syntax error so it should be here somewhere.

Error: Error In Execution
MYSQL Said: DB Error: syntax error

AddPage.php
PHP Code:

<?php

$no_need_to_display
=0;
if( isset(
$_POST["submit"]) )
{
    if( 
is_array($_POST) )
    {
        while( list(
$k$v) = each($_POST) )
        {
            $
$k=$v;
        }
        @
reset($_POST);
    }
    if( empty(
$name)  )
    {
        
$error_messages[]=$smarty->get_config_vars('pagenamemiss');
    }
    if( empty(
$title)  )
    {
        
$error_messages[]=$smarty->get_config_vars('titlemiss');
    }

    if( empty(
$content)  )
    {
        
$error_messages[]=$smarty->get_config_vars('bodytextmiss');
    }

    if( 
count($error_messages) == )
    {
            
$now   time();
            
$query"insert into ".$prefix."_pages (name,title,content,priv,parentid,view) values
            ('
$name','$title','$content',$priv,$parentid,$view)";
            
$res $db->query($query);
            if (
DB::isError($res) )
            {
                
$error_messages[]="Error In Execution<br>MYSQL Said: ".$res->getMessage() ;
                
$smarty->assign('error_messages'$error_messages);
                
$smarty->assign('width'"50%");
                
$smarty->display("errors_table.tpl");
            }
            else
            {
                
$message_title $error_messages[]=$smarty->get_config_vars('success');
                
$messages[] = $error_messages[]=$smarty->get_config_vars('opsuccess');        
                
$smarty->assign('message_title'$message_title);
                
$smarty->assign('messages'$messages);
                
$smarty->assign('width'"50%");
                
$smarty->display("admin_messages.tpl");
                
$no_need_to_display=1;
            }
    }
    else
    {
        
$smarty->assign('error_messages'$error_messages);
        
$smarty->assign('width'"50%");
        
$smarty->display("errors_table.tpl");
    }
}

if(
$no_need_to_display==0)
{
$query"SELECT * FROM ".$prefix."_pages WHERE parentid = 0";
$pages $db->getAll($query);
$smarty->assign('pages'$pages);            
$smarty->display("addpage.tpl");
}
else
{
$smarty->display("default.tpl");
}
?>

AddPage.tpl (snippet)

Code:
<tr>
<td align="right">
<input type="checkbox" name="view" value="1" {if 1 eq $smarty.request.view|default:$cat.view}checked="checked"{/if} />
</td>
<td align="left">
Link tonen in het menu
</td>
</tr>
SQL

Code:
CREATE TABLE be_pages ( 
ID bigint(20) unsigned NOT NULL auto_increment,
parentid bigint(20) unsigned NOT NULL ,
name varchar(255) NOT NULL ,
title varchar(255) NOT NULL ,
content text NOT NULL ,
views bigint(20) unsigned NOT NULL ,
priv smallint(2) unsigned NOT NULL ,
view tinyint(1) unsigned NOT NULL ,
sortorder int(11) unsigned NOT NULL ,
PRIMARY KEY (ID)
);

Last edited by Christian; 04-18-06 at 07:04 PM. Reason: Please use [PHP][/PHP] when posting PHP code!
Reply With Quote