Current location: Hot Scripts Forums » Programming Languages » PHP » MySQL Syntax error

MySQL Syntax error

 
Prev Previous Post   Next Post Next
  #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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax error phpprobid frankic PHP 6 05-20-06 01:33 AM
MySQL Syntax error when using a variable for table name lppa2004 PHP 4 08-04-05 01:24 AM
MySQL syntax error HairySpider PHP 2 07-12-05 07:43 AM
Can't find error in sql syntax. Dr.Jamescook PHP 7 06-14-05 12:45 PM
You have an error in your SQL syntax. Help! SevEre PHP 7 09-08-04 06:05 AM


All times are GMT -5. The time now is 01:49 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.