Welcome Guest, Not a member yet? Register   Sign In
cant get to work site_url in anchor
#1

[eluser]Edgars[/eluser]
Code:
class Welcome extends Controller {
function __construct()         {
            parent::Controller();
            $this->load->helper('url');
       }
    function Welcome()    {
        parent::Controller();    
    }
    
    function index()    {
        $this->load->view('welcome_message');
    }
    function content()    {
         echo "asdf";
    }
    
}
This is my controller - Welcome
Code:
<body>

<?php
echo anchor('/welcome/content', 'title="My News"');
?>

</body>
and my welcome_message.php
All is taken from codeigniter user_guide.
And
The requested URL /index.php/welcome/content was not found on this server.
this is what I get when I click on link. Why it ain't working?
#2

[eluser]Bart v B[/eluser]
You have already a 'Welcome' controller.
So you just have to remove your other welcome segement.

Code:
<?php
class Welcome extends Controller
{
  function __construct()
  {
     parent::Controller();
     $this->load->helper('url');
  }
        
  function index() // this is what loads when you call welcome
  {
    $this->load->view('welcome_message');
  }
    
  function content()  // this will be loaded welcome/content/  
  {
    echo "asdf";
  }
#3

[eluser]Edgars[/eluser]
I removed it and it still are not working.
#4

[eluser]Bart v B[/eluser]
Is your pc jumping...? Tongue what is not working..
Errors please.. its very difficult to help without to see what your doing.
#5

[eluser]Edgars[/eluser]
Not Found
The requested URL /index.php/welcome/content was not found on this server.
Apache Server at example.com Port 80


Same error as before. Reinstalled wamp server and codeigniter.
When I try using that link I made, he throws me to
http://example.com/index.php/welcome/content and shows error instead 'asdf'
But when I enter manually in adress bar
http://localhost/index.php/welcome/content, I got echo'ed 'asdf' as it is supposed to.

Ah when I posted reply, I saw my problem. Had to change
$config['base_url'] = "http://example.com/";
to
$config['base_url'] = "http://localhost/";
in config file Smile Now im good. Thanks

<?php

class Welcome extends Controller {
function __construct() {
parent::Controller();
$this->load->helper('url');
}
function index() {
$this->load->view('welcome_message');
}
function content(){
echo "asdf";
}
}
?>
Code:
<body>

<?php
echo anchor('/welcome/content', 'title="My News"');
?>

</body>




Theme © iAndrew 2016 - Forum software by © MyBB