Welcome Guest, Not a member yet? Register   Sign In
Disallowed Key Characters. ???
#1

[eluser]boomr[/eluser]
Heey every body

i have a same problem
whit submitting a form


if i try to post a comment i get the error

Disallowed Key Characters.

and then if i press renew i get

A Database Error Occurred
You must use the “set” method to update an entry.

here’s my code

blog.php


Code:
<?php

class Blog extends controller {
  function Blog()
  {  
      parent::Controller();
      
      $this->load->helper(‘url’);
      $this->load->helper(‘form’);  
  }
  function index()
  {
      $data[‘title’] = “My Blog Title”;
      $data[‘heading’] = “My Blog Heading”;
      $data[‘query’] = $this->db->get(‘entries’);
      
      $this->load->view(‘blog_view’, $data);
  
  }
  function comments()
  {  
  
      $data[‘title’] = “My comment Title”;
      $data[‘heading’] = “My comment Heading”;
      $this->db->where(‘entry_id’, $this->uri->segment(3));
      $data[‘query’] = $this->db->get(‘comments’);
  
      $this->load->view(‘comment_view’, $data);
      
  }
  function comment_insert()
  {
      $this->db->insert(‘comments’, $_POST);
      redirect(‘blog/comments/’.$_POST[‘entry_id’]);
      }
}
?>

comment_view.php

Code:
<html>
<head>
<title><?=$title?></title>
</head>
<body>
<h1>&lt;?=$heading?&gt;</h1>
&lt;?php if ($query->num_rows() > 0): ?&gt;
  &lt;?php foreach($query->result() as $row): ?&gt;
  &lt;?=$row->body?&gt;
  &lt;?=$row->author?&gt;
  <hr>
  &lt;?php endforeach; ?&gt;
&lt;? endif; ?&gt;
&lt;?=anchor(‘blog’, ‘back to blog’);?&gt;
&lt;?=form_open(‘blog/comment_insert’);?&gt;
&lt;?=form_hidden(‘entry_id,’, $this->uri->segment(3));?&gt;
&lt;textarea name=“body” rows=“10”&gt;&lt;/textarea>
&lt;input type=“text” name=“author” /&gt;&lt;/p>
&lt;input type=“submit” value=“Submit Comment”/&gt;&lt;/p>
&lt;/body&gt;
&lt;/html&gt;

blog_view.php

Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;&lt;?=$title?&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<h1>&lt;?=$heading?&gt;</h1>
&lt;?php foreach($query->result() as $row): ?&gt;

&lt;?=$row->title?&gt;
&lt;?=$row->body?&gt;
&lt;?=anchor(‘blog/comments/’.$row->id, ‘Comments’);?&gt;
<hr>
&lt;?php endforeach; ?&gt;
&lt;/body&gt;
&lt;/html&gt;


already thanks for the help
#2

[eluser]Deveron[/eluser]
Hi Danko,

the problem is in your comment_view.php.

Code:
&lt;?=form_hidden(‘entry_id,’, $this->uri->segment(3));?&gt;

Remove the comma inside the fieldname definition.

Cheers
#3

[eluser]boomr[/eluser]
Heeey

Thank you sooo much soo stupid of me that i didn't see it ;s


Greetings
#4

[eluser]boomr[/eluser]
i posted 1 comment but now is get this :S

A Database Error Occurred
Error Number: 1062

Duplicate entry '0' for key 1

INSERT INTO `comments` (`entry_id`, `body`, `author`) VALUES ('1', 'test', 'test')


greetings
#5

[eluser]Deveron[/eluser]
The "entry_id" is the primary key in your comment database.?
A primary key is unique, so it is not possible to have two entrys with the same primary key.
Don't put the entry_id in your data array if you do inserts or updates.
#6

[eluser]boomr[/eluser]
Thank you again soo muche

i just started 2 weeks ago whit learning php and about data structure so i am realy glad that you helped me a little whit it

thanks again soo much greetings




Theme © iAndrew 2016 - Forum software by © MyBB