• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
create a blog under 20 minutes problem...

#1
[eluser]iLoveChocolate[/eluser]
Hi recently I have been following a tutorial.
"Creating a Blog under 20 minutes"

I believe I have been following the code very thoroughly.
I have done the
- blog.php
- comment_view.php
- blog_view.pphp

Unfortunately when I put the anchor into the
<p>&lt;?php echo anchor('blog/comments/', 'Comment'); ?&gt;</p>

The webpage does show up the index.php but when I pressed the COMMENT link
The webpage does not show up the comments function!!!

There is also an error with with the Scalffolding!
I could not create a new record and view records!!!
This is very frustrating.

Please some one help me... I really need help. I have double check my config files, codes, re-winding the video and I have been sitting here for hours trying to figure out the problems but I can't.

Thank you very much in advance.

#2
[eluser]iLoveChocolate[/eluser]
I will be glad to send you the files.

#3
[eluser]iLoveChocolate[/eluser]
Below is the code, I copied from the tutorial.

there are 1 database and 2 tables:

DB name = blog
Table name = comments, entry

copy paste the comments SQL below into MYSQL:

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected]@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;


CREATE TABLE IF NOT EXISTS `comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`entry_id` int(11) NOT NULL,
`body` text NOT NULL,
`author` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */;
/*!40101 SET [email protected]_CHARACTER_SET_RESULTS */;
/*!40101 SET [email protected]_COLLATION_CONNECTION */;'

------------------------------------------------------------------------------------------

Copy paste the entry SQL into the MYSQL

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected]@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;


CREATE TABLE IF NOT EXISTS `entry` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(128) NOT NULL,
`body` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

INSERT INTO `entry` (`id`, `title`, `body`) VALUES
(1, 'My First Post', 'Im a Millionaire'),
(2, 'My Second post', 'Im going to become a Multi Millionaire when I am 22');

/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */;
/*!40101 SET [email protected]_CHARACTER_SET_RESULTS */;
/*!40101 SET [email protected]_COLLATION_CONNECTION */;

#4
[eluser]iLoveChocolate[/eluser]
blog.php PHP code.
Feel free to change or fix it. I do not where the problem lays. But this is what I have follow so far from the tutorial. Please help me =)

&lt;?php
class Blog extends Controller{

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

$this->load->helper('url');
$this->load->helper('form');

$this->load->scaffolding('entry');
}
function index()
{
$data['title'] = "My Blog Title";
$data['heading'] = "My Blog Heading";
$data['query'] = $this->db->get('entry');// Get from the entries table

$this->load-> view('blog_view', $data);
}

function comments()
{
$data['title'] = "My Comment Title";
$data['heading'] = "My Comment Heading";

$this->load->view('comment_view', $data);
}

function comment_insert()
{
$this->db->insert('comments', $_POST);

redirect('blog/comments/'.$_POST['entry_id']);
}

}
?&gt;

#5
[eluser]iLoveChocolate[/eluser]
blog_view.php

&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>

<ol>
&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', 'Comment'); ?&gt;</p>
<hr>
&lt;?php endforeach; ?&gt;
</ol>
&lt;/body&gt;
&lt;/html&gt;

#6
[eluser]iLoveChocolate[/eluser]
comment_view.php

&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;?php if($query->num_rows()>0): ?&gt;

&lt;?php echo foreach($query->result() as $row): ?&gt;

<p>&lt;?php echo $row->body; ?&gt;</p>
<p>&lt;?php echo $row->author; ?&gt;</p>

<hr>
&lt;?php endforeach;?&gt;
&lt;?php endif; ?&gt;

&lt;?php echo form_open('blog/comment_insert'); ?&gt;

&lt;?php echo form_hidden('entry_id', $this->uri->segment(3)); ?&gt;
&lt;/form&gt;
<p>&lt;textarea name = "body" rows = "10"&gt; &lt;/textarea&gt; </p>
<p>&lt;input type = "text" name = "autor" /&gt;&lt;/p>
<p>&lt;input type = "submit" value = "Submit Comment" /&gt; </p>

&lt;/body&gt;
&lt;/html&gt;

#7
[eluser]lenwood[/eluser]
Did you ever figure this out?

#8
[eluser]Dan Horrigan[/eluser]
My guess from a quick glance is that he had this:
Code:
&lt;?php echo anchor(‘blog/comments/’, ‘Comment’); ?&gt;

But needed this:
Code:
&lt;?php echo anchor(‘blog/comments’, ‘Comment’); ?&gt;

Notice he had added a trailing '/' in the first parameter of the anchor function.

#9
[eluser]iLoveChocolate[/eluser]
&lt;?php echo anchor(‘blog/comments’, ‘Comment’); ?&gt;

Cool, i'll try that as soon as possible and I will post it to you as soon as possible too. =D

Currently I am learning JSP and I find it so easy compare to PHP and secure but ofcourse heavier in term of performance, but it just the matter of the design.

Dan Horrigan, thanks for the good eyes you have! hahahaha, once again I will post it to you about the result.

See ya

#10
[eluser]iLoveChocolate[/eluser]
@Len wood

hahahaha no I never ever figured this out hahahaha.
Im not really good at spotting problems. Grkkkk

Yeah i'll post you about the solution given from Dan Horrigan. Thanks man!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.