Welcome Guest, Not a member yet? Register   Sign In
Question about The Video Tutorials.
#11

[eluser]aussie1855[/eluser]
First of all thanks LAB ASSISTANT, you help has really been appreciated.

Nearly ther now just have an error with blog.php

<?php

class Blog extends controller {

function index ()
{
$data[‘title’] = “My Blog Page”;
$data[‘heading’] = “My Blog Heading”;
$this->load->view('blog_view' , $data);
}
}

?>



Parse error: syntax error, unexpected T_STRING in /usr/home/ashbyrut/public_html/CodeIgniter/blog.php on line 7


However I cant see what is wrong


Thanks

Michael
#12

[eluser]NateL[/eluser]
I don't see anything wrong with it either. I've just adjusted the single and double quotation marks...looks like something you'd copy out of MS Word...heh..

Code:
<?php

class Blog extends Controller {

  function index()
  {
      $data['title']  =  "My Blog Page";
      $data['heading']  =  "My Blog Heading";  
      $this->load->view('blog_view' , $data);
  }
}

?>

Try that and see if it works...if that doesn't work..we need to look at your sites structure.

/public_html/CodeIgniter/blog.php

blog.php should be in the /application/controllers folder.
#13

[eluser]NateL[/eluser]
Also, check out my signature and look at the CodeIgniter from Scratch series by Jeffrey Way. You will pick up some good information from his tutorials.

The video tutorials on the CodeIgniter home page are out dated.
#14

[eluser]aussie1855[/eluser]
In regards to your very last post Lab Tech I have now switched to that series of tutorials and thanks for the suggestion.

I have gotten further with them but still have a problem. if i use the file path /CI/index.php I can get the 'welcome page' and did so until i got to the part where we started adding the data array.

Now I get the following error:

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /CI/application/controllers/site.php:1)

Filename: codeigniter/Common.php

Line Number: 356
An Error Was Encountered

Unable to load the requested file: home , $data.php


I was wondering if you could help me with this problem now. Below are the two php files.

site.php -->

<?php

class Site extends controller {

function index()
{
$data['myValue'] = "My Value";
$data['anotherValue'] = "Another Value";
$this->load->view('home , $data');
}
}

?>


home.php -->
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>
<div id="contianer">
<p> My view has been loaded </p>
<p> &lt;?php echo $myValue; ?&gt; </p>
<p> &lt;?php echo $anotherVallue; ?&gt; </p>

</div>

&lt;/body&gt;

&lt;/html&gt;


Thanks once again for all the help.

Michael

PS the common.php mention is the same as it came.
#15

[eluser]NateL[/eluser]
Again, your quotes are in the wrong place:

Code:
$this->load->view('home, $data');

should be:
Code:
$this->load->view('home' , $data);
#16

[eluser]aussie1855[/eluser]
You are very helpful and it has been most appreciated

Still have a problems. I get the following error message now:

Fatal error: Call to undefined method CI_DB_mysql_result::num_row() in /usr/home/ashbyrut/public_html/CI/application/models/site_model.php on line 8

Here are the php files:

site_model.php

&lt;?php

Class Site_model extends Model {

function getAll() {
$q = $this->db->get('ashbyrut_users');

if($q->num_row() > 0) {
foreach ($q->result() as $row){
$data[] = $row;
}
return $data;
}
}
}
?&gt;


home.php

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;&lt;/title>
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;/head&gt;

&lt;body&gt;
<div id="contianer">
<p> My view has been loaded </p>

<pre>
&lt;?php print_r($ashbyrut_users)?&gt;;
</pre>
</div>

&lt;/body&gt;

&lt;/html&gt;


site.php

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;&lt;/title>
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;/head&gt;

&lt;body&gt;
<div id="contianer">
<p> My view has been loaded </p>

<pre>
&lt;?php print_r($ashbyrut_users)?&gt;;
</pre>
</div>

&lt;/body&gt;

&lt;/html&gt;


Wondering if you can work out why the error occurs.


Many thanks


Michael
#17

[eluser]Colin Williams[/eluser]
it's num_rows(), with the 's'
#18

[eluser]jedd[/eluser]
And aussie1855, you now have enough posts under your belt to not have an excuse any more for avoiding [ code ] tags. It'll make your posts far more readable. Have a play.
#19

[eluser]aussie1855[/eluser]
Thanks guys you have been very patient with me.

First: As you can see I have now started using the
Code:
tags - let me know if I have used them incorrectly.

Second: progressing with this thread I now get the following error:

Fatal error: Call to undefined method CI_DB_mysql_driver::querry() in /usr/home/ashbyrut/public_html/CI/application/models/site_model.php on line 7

The pages are listed below:

site.php

[code]
&lt;?php


class Site extends controller{
    function index() {
        $this->load->model('site_model');
        $data['rows'] = $this->site_model->getAll();
        $this->load->view('home' , $data);        
        }
    
}

?&gt;

site_model.php

Code:
&lt;?php

class Site_model extends Model {

    function getAll() {
            $q = $this->db->querry("SELECT * FROM ashbyrut_users");        
            if($q->num_rows() > 0) {
                foreach($q->result() as $row){
                    $data[] = $row;
            }
            return $data;
        }
    }
}

?&gt;


home.php

Code:
&lt;html&gt;

    &lt;head&gt;
        &lt;title&gt;&lt;/title>
        &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
    &lt;/head&gt;
    
    &lt;body&gt;
        <div id="container">
            <p> My view has been loaded </p>
            
            &lt;?php foreach($rows as $r){
                echo '<h1>' . $r ->user_username . '</h1>' ;            
            }
            ?&gt;
        </div>

    &lt;/body&gt;

&lt;/html&gt;

Three: is there a programme/library/template that can check CodeIgniter code for error?


Again many thanks for the help with this


Michael

PS now I see what happens when you use the [code] tags - brilliant
#20

[eluser]jedd[/eluser]
[quote author="aussie1855" date="1258860767"]

First: As you can see I have now started using the
Code:
tags - let me know if I have used them incorrectly.
[/quote]

Smile You'll notice that whenever we talk about them, we put a space after the [ - such as [ code ] tags. Otherwise it drops you into the code format no matter what you wanted it to do.


Quote:
Code:
$q = $this->db->querry("SELECT * FROM ashbyrut_users");

query has one less r than you might think.

As to debugging .. I've been pondering writing up a blurb in the wiki, but I've only had a modicum of success getting people to rabbit on about their approaches to things. There's nothing hugely special about the way CI handles the debugging process - above and beyond your standard PHP approaches that is.

I picked this code snippet up from here - slightly modified - and it lives in my standard helper file that gets used in every project. It means I can call - from anywhere - something like:
Code:
dump ($foo_variable_I_am_wondering_about);

The code looks like this:
Code:
// ------------------------------------------------------------------------
/**
* Super Dump!
*
* Takes one parameter, and var_dumps that sucker (well, it print_r's
* it at the moment as it produces a tighter output).
*
* @param anything The variable to var_dump() straight to screen.
**/
function  dump ($var)  {
    // echo "<pre>".__FILE__.' @ line: '.__LINE__ .'<br />Result: ';
    echo "<pre>";
    if (isset ($var))
        if ($var)
            print_r ($var);
        else
            echo "dump() value FALSE or NULL";
    else
        echo "dump() value not set.";
    echo "</pre>";
    } // end-function  dump ()

Uncomment the first line if you find it useful - I normally do not.

Also I've found occasions where print_r() was more useful than var_dump(), and also vice versa, so I'll often flit into the helper function and toggle it to the other. There's probably a neater way of dealing with the respective shortcomings of print_r / var_dump.

I'd suggest that you also investigate FireBug - an astonishingly useful tool, and I know that I barely scratch the surface of its functionality.




Theme © iAndrew 2016 - Forum software by © MyBB