Welcome Guest, Not a member yet? Register   Sign In
Video tutorial problem
#1

[eluser]DoctorG[/eluser]
G'day all!

Just wondering if anybody else has had any problems with following the blog video tutorial? I got up to about 1/4 way and ended up with problems.
My blog_view.php code is:

Code:
<html>
<head>
<title><?=$title?></title>
</head>
<body>
<h1>&lt;?=$heading?&gt;</h1>

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

        <h3>&lt;?=$row->$title?&gt;</h3>
        <p>&lt;?=$row->$body?&gt;</p>
        
        <hr>
        
    &lt;?php endforeach; ?&gt;

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

...and I get the following error:

Quote:My Blog Heading
A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$My Blog Title

Filename: views/blog_view.php

Line Number: 10

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: body

Filename: views/blog_view.php

Line Number: 11


I would appreciate any help....Kind thanks,
Darren
#2

[eluser]LuckyFella73[/eluser]
Try this:
Code:
// ...
<h3>&lt;?=$row->title?&gt;</h3>
<p>&lt;?=$row->body?&gt;</p>
// ...

the "$" have to be removed
#3

[eluser]DoctorG[/eluser]
Thank you so much for that LuckyFella73. I didn't see that and I should have Wink

It worked...of cause. Thanks.
Darren
#4

[eluser]thepcfacer[/eluser]
I have the same code in my body, but my page is not displaying the contents. Anyone have the same issue?

Code:
Code:
<h3>&lt;?=$row->title?&gt;</h3>
<p>&lt;?=$row->body?&gt;</p>

Displays:
Quote:My Blog Heading
title?&gt;

body?&gt;
--------------------
title?&gt;

body?&gt;
--------------------
#5

[eluser]steelaz[/eluser]
Perhaps your PHP short tags are turned of, try

Code:
<h3>&lt;?php echo $row->title ?&gt;</h3>
<p>&lt;?php echo $row->body ?&gt;</p>
#6

[eluser]thepcfacer[/eluser]
Thanks for the help!
#7

[eluser]DoctorG[/eluser]
[quote author="steelaz" date="1254095680"]Perhaps your PHP short tags are turned of, try

Code:
<h3>&lt;?php echo $row->title ?&gt;</h3>
<p>&lt;?php echo $row->body ?&gt;</p>
[/quote]

Yes although
Code:
&lt;?=$row->title ?&gt;
is a nice short cut way, it is probably better for readability to type it as
Code:
&lt;?php echo $row->title ?&gt;
. And as steelas mentioned, the
Quote:&lt;?php ?&gt;
method would be more portable.

My opinion anyway...and still learning Wink
Regards




Theme © iAndrew 2016 - Forum software by © MyBB