• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Segment troubles + new problem

#1
[eluser]Jesse2303[/eluser]
Hi all

A word before
Yes, I have red the user docs.
Yes, I tried to solve this on my own, but I can't solve this.

Ok, here we go. I have a fucntion that calls nieuws_bekijk and I have a view file nieuws_bekijk_view.php

Well , when I run the script, it says:

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Main::$url

Filename: controllers/main.php

Line Number: 62

Quote:Fatal error: Call to a member function segment() on a non-object in C:\UsbWebserver\Root\ciAdmin\system\application\controllers\main.php on line 62

What I need to do ?

The function
Code:
function nieuws_bekijk() {
        
        $this->db->where('nieuwsid', $this->url->segment(3));
        $data['query']= $this->db->get('nieuws');
        
        $this->load->view('nieuws_bekijk_view');
    }

nieuws_bekijk_view.php
Code:
<!-- Kleine stijlwijziging van het extern stijlbestand -->
<style type="text/css">
.style7 {font-size: 12px; font-weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif; color: #FFFFFF; }
.style16 {
    font-size: 12px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    color: #000000;
}
.style17 {color: #000000}
</style>

<!-- Login check -->

<?php if(isset($_SESSION['gebruiker'])) { ?>

<?php foreach($query->result() as $row):?>
    
    <!-- Tabel waar het nieuws instaat. -->
    <table width="100%" border="0">
    
        &lt;!-- Naam --&gt;
        <tr>
            <td width="31%" bgcolor="#90897a" class="style7"><div align="right">Naam</div></td>
            <td width="69%" bgcolor="#e1ddd9" class="style16">&lt;?php echo $row->admin; ?&gt;</td>
          </tr>
          &lt;!-- Datum --&gt;
        <tr>
            <td bgcolor="#90897a" class="style7"><div align="right">Datum</div></td>
            <td bgcolor="#e1ddd9" class="style16">&lt;?php echo date('D d, F, Y H:i', $row->datum); ?&gt;</td>
        </tr>
        &lt;!-- Onderwerp --&gt;
        <tr>
            <td bgcolor="#90897a" class="style7"><div align="right">Onderwerp</div></td>
            <td bgcolor="#E1DDD9"  class="style16">&lt;?php echo $row->onderwerp; ?&gt;</td>
          </tr>
          &lt;!-- Bericht --&gt;
          <tr>
              <td align="right" valign="top" bgcolor="#90897a" class="style7"><div align="right">Bericht</div></td>
            <td align="left" valign="top" class="style16">&lt;?php echo nl2br($row->bericht); ?&gt;</td>
          </tr>
    
    </table>
    

&lt;?php endforeach; ?&gt;

&lt;!-- Niet ingelogd --&gt;

&lt;?php } else { ?&gt;

    <p>
        U moet inloggen om deze pagina te bekijken.
    </p>

&lt;?php } ?&gt;

#2
[eluser]parrots[/eluser]
The segment method is on the uri class, not the url helper. Change

Code:
$this->db->where('nieuwsid', $this->url->segment(3));

to

Code:
$this->db->where('nieuwsid', $this->uri->segment(3));

#3
[eluser]Jesse2303[/eluser]
[quote author="parrots" date="1214332947"]The segment method is on the uri class, not the url helper. Change

Code:
$this->db->where('nieuwsid', $this->url->segment(3));

to

Code:
$this->db->where('nieuwsid', $this->uri->segment(3));
[/quote]

Thanks it worked


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.