Welcome Guest, Not a member yet? Register   Sign In
$this->db->get-> throwing errors (straight from tutorial)
#1

[eluser]burnzide[/eluser]
I'm just mimicking http://codeigniter.com/tutorials/watch/blog/ and have hit a snag.

Code:
$data['query'] = $this->db->get->('entries');

is throwing

Code:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `'{'' or `'$'' in ...dev\ci\system\application\controllers\blog.php on line 21

I added database to the autoload and got no errors there. Copying everything from the video near-verbatim and I can't figure out what is causing this. I've tried a few other things to "set up" the query but the error pops on the ->db->get-> line every time, without fail.

What am I doing wrong?

Thanks.
#2

[eluser]jedd[/eluser]
Is that line 21 that you quoted?

Can you post the entire block of code. (Though I am mostly curious about line 20.)
#3

[eluser]pistolPete[/eluser]
This is just a PHP syntax error, the last -> is too much.
Code:
$data['query'] = $this->db->get('entries');
#4

[eluser]burnzide[/eluser]
Ahh, thanks! Been a while since I've touched this stuff :o I had a feeling it was something incredibly dumb.

Snagged me up enough to suck up my pride, register here, and make a post. Sigh.

Thank you. Smile
#5

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter community. Please feel free to return to the forums as often as you like. You'd be surprised what you can learn here. Smile
#6

[eluser]burnzide[/eluser]
Bleh, new problem.

var_dump :
Code:
["query"]=>
  object(CI_DB_mysql_result)#12 (7) {
    ["conn_id"]=>
    resource(28) of type (mysql link)
    ["result_id"]=>
    resource(29) of type (mysql result)
    ["result_array"]=>
    array(0) {
    }
    ["result_object"]=>
    array(0) {
    }
    ["current_row"]=>
    int(0)
    ["num_rows"]=>
    int(3)
    ["row_data"]=>
    NULL

num_rows is correct depending on which table I query but I can't manage to get meaningful data.

Code:
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
are both set correctly. :/
#7

[eluser]pistolPete[/eluser]
What query are you running exactly? Post your code please.

$data['query'] is an object. In order to get the "real" results you have to use a function from here:
Generating Query Results
#8

[eluser]burnzide[/eluser]
edit: ARGH typos.

Disregard.

Last time I touched PHP was version 3, been a while, not caught up with all the OO syntax. I've got things working now. Thanks for the very quick help. This framework thing is pretty exciting after having done all my pl/cgi and php stuff from scratch in the past Smile




Theme © iAndrew 2016 - Forum software by © MyBB