Welcome Guest, Not a member yet? Register   Sign In
anchor() generates wrong links?
#1

[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.
#2

[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?
#3

[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)
#4

[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
#5

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

[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/Th...news-posts

when it should be

http://localhost:8888/index.php/news/arc...news-posts


any help? thanks!!

grant
#7

[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";
#8

[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'] = "";
#9

[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.
#10

[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/";




Theme © iAndrew 2016 - Forum software by © MyBB