Note that there are some explanatory texts on larger screens.

plurals
  1. POcodeigniter update function gets 404
    primarykey
    data
    text
    <p>I have created an update function but i keep getting a 404 error, i cant figure out what seems to be the problem. help would be appriciated thank you .</p> <p>controller news.php</p> <pre><code> public function update($id) { $id = $this-&gt;uri-&gt;segment(3); $data = array( 'title' =&gt; $this-&gt;input-&gt;post('title'), 'text' =&gt; $this-&gt;input-&gt;post('text'), 'slug' =&gt; $this-&gt;input-&gt;post('slug'), ); if($this-&gt;news_model-&gt;exists($id)) { $this-&gt;news_model-&gt;update($id, $data); } else { $this-&gt;news_model-&gt;insert($data); } } </code></pre> <p>news_model.php</p> <pre><code>public function update_news($id, $data) { $this-&gt;db-&gt;where('id', $id); $this-&gt;db-&gt;update('news', $data); } </code></pre> <p>route</p> <pre><code>$route['news/update/(:num)'] = 'news/update/$1'; </code></pre> <p>views</p> <p>update.php</p> <pre><code> &lt;h2&gt;Update an item&lt;/h2&gt; &lt;?php echo validation_errors(); ?&gt; &lt;?php echo form_open('/news/update'.$news_item['id']) ?&gt; &lt;label for="title"&gt;Title&lt;/label&gt; &lt;input type="input" name="title" /&gt;&lt;br /&gt; &lt;label for="slug"&gt;Slug&lt;/label&gt; &lt;input type="input" name="slug" /&gt;&lt;br /&gt; &lt;label for="text"&gt;Text&lt;/label&gt; &lt;textarea name="text"&gt;&lt;/textarea&gt;&lt;br /&gt; &lt;input type="submit" name="submit" value="Update an item" /&gt; &lt;/form&gt; </code></pre> <p>index.php</p> <pre><code> &lt;p&gt;&lt;a href="news/update/&lt;?php echo $news_item['id'] ?&gt;"&gt;update article&lt;/a&gt;&lt;/p&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload