Wrox Programmer Forums
|
BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
This is the forum to discuss the Wrox book Professional CodeIgniter by Thomas Myer; ISBN: 9780470282458
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 11th, 2010, 12:58 AM
Authorized User
 
Join Date: Jan 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mehdymahmood
Default Cant load page with anchor

i have load url helper , but when i am trying to load from home page with anchor , it says server dont find ,

my view file home.php

<div id = 'pleft'>
<?php
echo "<img src ='".$mainf['image']."' border = '0' align = 'left' />\n";
echo "<h2>" .$mainf['name']."</h2>\n";
echo "<p>" .$mainf['shortdesc']. "<br/>\n" ;
echo anchor('welcome/product/'.$mainf['id'],'see details') . "<br/>\n";
echo anchor ('welcome/cart/'. $mainf['id'],'buy now') . "</p>\n";
?>
</div>

and my controller welcome.php

<?php

class Welcome extends Controller {

function Welcome()
{
parent::Controller();

}

function index()
{


$data['title'] = "Welcome to desinator";
$data['navlist'] = $this->MCats->getAllCategories();
$data['mainf'] = $this->MProducts->getMainFeature();
$skip = $data['mainf']['id'];
$data['sidef'] = $this->MProducts->getRandomProducts(3,$skip);
$data['main'] = 'home';
$this->load->vars($data);
$this->load->view('template');
}





function product($id){
$product = $this->MProducts->getProduct($id);
if (!count($product)){
redirect('welcome/index','refresh');
}
$data['grouplist'] = $this->MProducts->getProductsByGroup(3,$product['grouping'],$id);
$data['product'] = $product;
$data['title'] = "Claudia's Kids | ". $product['name'];
$data['main'] = 'product';
$data['navlist'] = $this->MCats->getCategoriesNav();
$this->load->var($data);
$this->load->view('template');

}


}

my template.php in view ,

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php echo $title; ?></title>
<link href="<?php base_url();?>css/default.css" rel="stylesheet" type="text/css" />


<script type="text/javascript">
//<![CDATA[
base_url = '<?php base_url();?>';
//]]>
</script>
</head>
<body>
<div id="wrapper">
<div id="header">
<?php $this->load->view('header');?>

</div>

<div id="nav">
<?php $this->load->view('navigation');?>
</div>

<div id="main">
<?php $this->load->view($main);?>

</div>

<div id="footer">
<?php $this->load->view('footer');?>
</div>
</div>

</body>
</html>


my index load perfectly but when ever i clik any link , it cant find the sever ,
Not Found

"The requested URL /codeigniter/welcome/product/1 was not found on this server. " please help me .
 
Old January 11th, 2010, 03:21 AM
Registered User
 
Join Date: Jan 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code typo?

Could this typo have anything to do with it?

Code:
function product($id){
$product = $this->MProducts->getProduct($id);
if (!count($product)){
redirect('welcome/index','refresh');
}
$data['grouplist'] = $this->MProducts->getProductsByGroup(3,$product['grouping'],$id);
$data['product'] = $product;
$data['title'] = "Claudia's Kids | ". $product['name'];
$data['main'] = 'product';
$data['navlist'] = $this->MCats->getCategoriesNav();

$this->load->var($data); <---- Should be $this->load->vars($data);

$this->load->view('template');

}
Bob
 
Old January 11th, 2010, 03:31 AM
Authorized User
 
Join Date: Jan 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mehdymahmood
Default

thank you bob, you were right , i had an typo , just correct it , but still the same problem . the page dont load when i clik any link .

mehdy
 
Old January 11th, 2010, 07:00 AM
Authorized User
 
Join Date: Jan 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mehdymahmood
Default

I have alternative check my problem , so create a simple controller and view file , and find that actually my function of the class dont loading ,

my controller text.php
<?php


class Test extends Controller {

function Test() {
{

parent::Controller();
}

function index () {

$this->load->view('test');

}

function check (){

echo "ee";
}


}


my view file text.php

<html>
<head>
<title></title>
<meta http-equiv = "Content-Type" content = "text/html ; charset =UTF-8" >
</head>
<body>
<div id ="container" >

<?php echo "gggg";

echo anchor('test/check' ,'new')

?>
</div>
</body>
</html>

when the index.php load perfectly , but when i clik on the link , it say ,
it dont find the server . what may the problem , please help me .
 
Old January 11th, 2010, 08:29 AM
Registered User
 
Join Date: Jan 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Check your config

ah right ok, I think your codeigniter setup is not quite right. Check the file config.php and particularly the $config['base_url'] setting.

Mine looks like this but yours might be slightly different.
Code:
$config['base_url']	= "http://localhost/codeigniter/";
Hope that helps,
Bob
 
Old January 11th, 2010, 11:11 AM
Authorized User
 
Join Date: Jan 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mehdymahmood
Default

thank you bob , I have the same as yours . still its not working , when ever i click the link , it shows errors ,
 
Old January 11th, 2010, 01:43 PM
Registered User
 
Join Date: Jan 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need input...

Hi Mehdy,

You need to provide a little more info here, in particular the urls that are being displayed in your browser. Try bypassing the views and calling controller functions directly. Check the codeigniter forums too as others have probably experienced these same setup issues.

You should also check all your log files as these may give you a clue as well.

It may also be worth downloading the source to this book as it contains a fully working CI installation, you just need to update the config.php and database.php to match your system.

HTH,
Bob
 
Old January 11th, 2010, 02:13 PM
Authorized User
 
Join Date: Jan 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mehdymahmood
Default

thank you bob
config.php
$config['base_url'] = "http://localhost/codeigniter/";
$config['index_page'] = "";

routes.php
$route['default_controller'] = "test";

autoload.php
$autoload['libraries'] = array('database','session','email','validation');

$autoload['helper'] = array('url','form','text','date','security');

htaccess.txt

RewriteEngine on
RewriteCond $1 !^(index\.php|images|captcha|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

/codeigniter/system/application/controllers/
i have connect with db ,
do i need to change any configuration ?
 
Old January 11th, 2010, 03:04 PM
Registered User
 
Join Date: Jan 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Strip everything back to default

Take .htaccess and any url rewriting out of the equation, you want to simplify your configuration as much as possible.

Remove your .htaccess file and set the Index file back to default:
Code:
$config['index_page'] = "index.php";
Undo any other modifications beyond the bare essentials that you may have made.

If you still see a problem then post the urls you are seeing in your browser.

Bob
 
Old January 11th, 2010, 03:16 PM
Authorized User
 
Join Date: Jan 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mehdymahmood
Default

thank you bob, done it , still no change





Similar Threads
Thread Thread Starter Forum Replies Last Post
link to anchor in a db-generated page scottiegirl PHP Databases 4 March 11th, 2008 12:19 PM
page could not be load on browser vivek123 ASP.NET 1.0 and 1.1 Professional 2 August 28th, 2006 05:01 AM
Page won't load data in IE rinventive PHP How-To 8 June 23rd, 2006 10:03 PM
page load() task vijayapteET Classic ASP Basics 1 October 3rd, 2005 10:19 PM
Page Load event qadeer05 ASP.NET 1.0 and 1.1 Basics 5 July 19th, 2004 08:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.