
04-18-06, 03:14 AM
|
|
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) == 0 )
{
$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 06:04 PM.
Reason: Please use [PHP][/PHP] when posting PHP code!
|

04-18-06, 06:28 AM
|
 |
Code Guru
|
|
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by gigafare
PHP Code:
$query= "insert into ".$prefix."_pages (name,title,content,priv,parentid,view) values
('$name','$title','$content',$priv,$parentid,$view)";
|
should look like this...
PHP Code:
$query= "insert into ".$prefix."_pages (name,title,content,priv,parentid,view) values
('".$name."','".$title."','".$content."','".$priv."','".$parentid.'","'.$view."')";
|

04-18-06, 12:31 PM
|
|
Newbie Coder
|
|
Join Date: Oct 2005
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Different kind of error this time:
• Error In Execution
MYSQL Said: DB Error: value count on row
|

04-18-06, 12:47 PM
|
 |
Community VIP
|
|
Join Date: Apr 2006
Location: Los Angeles, CA
Posts: 660
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Can you echo out the problematic query?
Also, is there any way to make your DB class give more verbose errors? These error descriptions aren't very useful...I've never used PEAR DB (I'm assuming that's what you're using?)
|

04-19-06, 02:03 AM
|
|
Newbie Coder
|
|
Join Date: Oct 2005
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I think this is the problem, if there's no need to display (a checkbox) is selected the link to this page isn't supposed to show in the menu. But see what happens: only SELECT * FROM ...?? Shouldn't this be Insert Into etc...?
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");
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|