Welcome Guest, Not a member yet? Register   Sign In
Trouble with the tutorials
#1

[eluser]The Beginner[/eluser]
Hi, My name is Del and I am new to PHP and Web Development so some of this stuff is out of my area of anything. I started with installing xamp as a php enabled web server. It seams to work well. I installed CI and started building the tutorial. The first one went exactly as in the video showed with no problems. The second was an entirely different story. The first issue I had was that the scaffolding screen would not add new records to the entries table. It would however display records if I entered them in MySQL Query Browser. It would not let me edit those records or add more, it simply went to a 404 page. I decided to continue with the comments part and I got as far as the echo test and it again went to a 404 page. I cnecked and rechecked to make sure I keyed everything in correctly. I am sure it may be something simple, (it usually is, lol). anyway if anyone has any suggestions as to why i am having trouble (other than the my ignorance, lol) I would really appreciate it.
Thanks,
Del
#2

[eluser]überfuzz[/eluser]
404 is trowed if theres no site under the qurrent url. Check if you've got a match between the url and the controller.

url
www.site.com/currentcontroller.php

controller
class Currentcontroller etc... //first letter is capital.
#3

[eluser]jedd[/eluser]
Hi Del, and welcome to the CI forums.

I wouldn't fret too much over some tutorials not working precisely to plan. Sure, it's good to work out why - satisfaction as well as the learning experience - but you might just want to head over to a different tutorial - attack the same problem from a different angle, as it were.

Scaffolding is all but deprecated - the feature still exists, but I gather it was never very fondly thought of by the authors. There are better tools - as you intimated using your MySQL gui - or even better, learn how to use the mysql command line interface, and also how to code up your test data into text files - so you can create and insert your test data with a one or two commands.

If you desperately want to work out why your current code isn't working, you'll have to start posting the relevant chunks of code to the forums - otherwise it'd all just be stabs in the dark.
#4

[eluser]The Beginner[/eluser]
Thanks for the responce. I really don't care to much about the scaffolding so much because as mentioned there are many ways to put in test data. But, I should be able to make the remainder of the tutorial work as shown. I am concerned about not being able to get it working. I am sure when I find the problem it will be some setting somewhere or maybe a typo on my part. At any rate below is the code from my blog tutorial project that does not work. If someone can tell me what I am doing wrong I would greatly appreciate it.

CONTROLLER CODE:
<?php
class Blog extends Controller
{
function Blog()
{
parent::Controller();
$this->load->helper('url');
$this->load->helper('form');
}

function index()
{
$data['title'] = 'My Blog Title';
$data['heading'] = 'My First Data Passing From Server To ie';
$data['query'] = $this->db->get('entries');

$this->load->view('blog_view',$data);
}
function comments()
{
$data['title'] = 'My Comment Title';
$data['heading'] = 'My First Comment Heading';
$this->load->view('comment_view',$data);
}
}
?>

BLOG_VIEW CODE:
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<h1>&lt;?php echo $heading; ?&gt;</h1>
&lt;?php foreach($query->result() as $row): ?&gt;
<h3>&lt;?php echo $row->title; ?&gt;</h3>
<p>&lt;?php echo $row->body; ?&gt;</p>
<p>&lt;?php echo anchor('blog/comments/'.$row->id, 'Comments'); ?&gt;</p>
<hr>
&lt;?php endforeach; ?&gt;
&lt;/body&gt;
&lt;/html&gt;

COMMENT VIEW
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<h1>&lt;?php echo $heading; ?&gt;</h1>
&lt;/body&gt;
&lt;/html&gt;
#5

[eluser]The Beginner[/eluser]
I just went back and ran my tutorial again and it is sending me to:

http://example.com/index.php/blog/comments/2

Any idea why?

This is my anchor line: &lt;?php echo anchor(‘blog/comments/’.$row->id, ‘Comments’); ?&gt;
#6

[eluser]The Beginner[/eluser]
Sorry guy's. I just found it. There is a setting in the Config.php file u nder application/config that says base url = ""; All I had to do was set that to my base url and it works. I probably missed that in the installation process. (Ok, so not only am I a beginner but a dummy as well.)
Thanks for the help.
Del




Theme © iAndrew 2016 - Forum software by © MyBB