CodeIgniter Forums
anchor() generates wrong links? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: anchor() generates wrong links? (/thread-15429.html)

Pages: 1 2 3


anchor() generates wrong links? - El Forum - 02-04-2009

[eluser]XORd[/eluser]
Here is what happened. I have the following code:

Code:
$items = $this->db->get('items')->result();

$links = '';
foreach($items as $item)
{
  $links .= anchor('item/view/' . $item->id, $item->title);
}

echo $links;

$links holds the links, each link pointing to its respective item, having the item's title.
However, the first link seems to come out broken.

Try it for yourself and see if you get any other result.
Of course, I was able to generate the correct link using base_url().

Just wondering if there's anything wrong with anchor()...

Thanks.


anchor() generates wrong links? - El Forum - 02-04-2009

[eluser]Edmundas KondraĊĦovas[/eluser]
[quote author="XORd" date="1233782310"]
However, the first link seems to come out broken.
[/quote]
Hi and welcome to CI forums, XORd.

Could you be more specific? What exactly do you mean by saying the link comes out broken?


anchor() generates wrong links? - El Forum - 02-04-2009

[eluser]XORd[/eluser]
Oh, dang!
I apologize!
Anchor() works perfectly!
It's me who replaced the period with a comma.
I'm sorry...

Thanks anyway...

(I wish I could remove this thread)


anchor() generates wrong links? - El Forum - 02-04-2009

[eluser]NateL[/eluser]
[quote author="XORd" date="1233798766"]

(I wish I could remove this thread)[/quote]
naw - someone else may have the same issue and find your thread, and you've solved more than your problem without doing a thing Smile


anchor() generates wrong links? - El Forum - 02-04-2009

[eluser]mandril[/eluser]
it would be better if you edit the title of the thread and add [SOLVED] before it =)


anchor() generates wrong links? - El Forum - 02-19-2009

[eluser]mindesign[/eluser]
How did you end up solving this? I'm currently having an issue where I use anchor() but it doesn't include the index.php in the link thus I get bad links

anchor($row['archive'],'(read more)');

results is

http://localhost:8888/news/archive/81/This-is-the-first-of-many-news-posts

when it should be

http://localhost:8888/index.php/news/archive/81/This-is-the-first-of-many-news-posts


any help? thanks!!

grant


anchor() generates wrong links? - El Forum - 02-19-2009

[eluser]mindesign[/eluser]
oh and my config file looks like so
Code:
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|    http://example.com/
|
*/
$config['base_url']    = "http://localhost:8888/";

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "index.php";



anchor() generates wrong links? - El Forum - 02-19-2009

[eluser]brianw1975[/eluser]
look in application/config/config.php

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "";


anchor() generates wrong links? - El Forum - 02-19-2009

[eluser]mindesign[/eluser]
[quote author="brianw1975" date="1235119589"]look in application/config/config.php

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "";[/quote]

Not too sure what you're saying here. I posted my config file in the post before.


anchor() generates wrong links? - El Forum - 02-19-2009

[eluser]brianw1975[/eluser]
sorry, shoulda read the OP closer..

are you using mod_rewrite (.htaccess file)?

also... out of curiosity... why did you change the base_url? you could have just added ':8888'

$config['base_url'] = (isset($_SERVER['HTTPS']) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].":8888/";