CodeIgniter Forums
MySQL, $query->result_array, and NginX - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: MySQL, $query->result_array, and NginX (/showthread.php?tid=42861)

Pages: 1 2


MySQL, $query->result_array, and NginX - El Forum - 06-22-2011

[eluser]cmd276[/eluser]
I have a project I'm working on developing.

I'm using Reactor 2.0.2.

I've had two main problems with CodeIgniter so far. (One I did a half fix on, it was URL problem. Not concerned.)
The other problem,

I have the following code in my News file.
Code:
/* Thigs before now ... */
        $query = $this->db->query("Get The News.");
        foreach($query->result_array() as $row)
        {
            /* Do things */}
/* Things after now.... */
The code works on my localhost, which I'm using to develop, it runs Apache, and when moved to the server, which runs nginx, the page (using Google Chrome) returns a Server 500. Others get a blank page, (Nothing in source)

I know the foreach is the line causing the death of my server, because I put in
Code:
die(print(__LINE__));
on several of the lines of the file. Removing each one, as it showed the file line it was being killed at until it returned the Server 500 error again.


What I would like to know, is what is it I need to supply for help.
Or, what can I do, to bypass the irreplaceable Database setup that CodeIgniter has?
I've talked to my host, he doesn't have a clue as to what is going on with this. (hes a system admin, and a coder. He's checked the code, as did I, for wondering white space, and haven't found anything)

I've looked into other frameworks, and find CodeIgniter to be the easiest for me to work with, and setup, and get going. I'd be awesome if I could get this problem fixed, so I could move on.

Thanks for your time!
~cmd276


MySQL, $query->result_array, and NginX - El Forum - 06-22-2011

[eluser]osci[/eluser]
Have you forgotten the get?
Code:
$query = $this->db->query("Get The News.")->get();
Also if you forgot it you are not checking if there are any returned rows.


MySQL, $query->result_array, and NginX - El Forum - 06-22-2011

[eluser]danmontgomery[/eluser]
[quote author="osci" date="1308750272"]Have you forgotten the get?
Code:
$query = $this->db->query("Get The News.")->get();
Also if you forgot it you are not checking if there are any returned rows.[/quote]

query() executes the query, get() is only used with AR syntax


MySQL, $query->result_array, and NginX - El Forum - 06-22-2011

[eluser]osci[/eluser]
soz about that, not careful enough.


MySQL, $query->result_array, and NginX - El Forum - 06-22-2011

[eluser]cmd276[/eluser]
[quote author="osci" date="1308750272"]Have you forgotten the get?
Code:
$query = $this->db->query("Get The News.")->get();
Also if you forgot it you are not checking if there are any returned rows.[/quote]

Going off of the User's Guide for Database Class, it doesn't mention anything about the '->get()' section. Also, going with I forgot to check for an empty result, it still returns a Server 500 with both things in place.

[quote author="noctrum" date="1308755270"][quote author="osci" date="1308750272"]Have you forgotten the get?
Code:
$query = $this->db->query("Get The News.")->get();
Also if you forgot it you are not checking if there are any returned rows.[/quote]

query() executes the query, get() is only used with AR syntax[/quote]
Not using the Active Record things.


MySQL, $query->result_array, and NginX - El Forum - 06-22-2011

[eluser]toopay[/eluser]
[quote author="cmd276" date="1308745408"]I've had two main problems with CodeIgniter so far. (One I did a half fix on, it was URL problem. Not concerned.)[/quote]

Oh dear. Sounds like htaccess crap for me.


MySQL, $query->result_array, and NginX - El Forum - 06-22-2011

[eluser]jmadsen[/eluser]
@cmd276 - it sounds like a server configuration issue to me, although I can't be too precise

-- does the same user for nginx also have permissions to run mysql?

-- are you able to run anything successfully on that server. For example, can you set up a simple php page that connects via php functions to the DB, completely without CodeIgniter?


MySQL, $query->result_array, and NginX - El Forum - 06-22-2011

[eluser]cmd276[/eluser]
@jmadsen - As for the user for nginx using mysql, I'm not sure how to answer this.

-- For the use of db stuff with out CodeIgniter, I can indeed run those functions, and connect with out it.


MySQL, $query->result_array, and NginX - El Forum - 06-22-2011

[eluser]jmadsen[/eluser]
@cmd276 - I was talking about the linux user assigned to running those two processes. it sounds like you are ok, but your sys admin would be able to tell you right away.

toopay might be right about your .htaccess, or your routing might have some problem on the live server.

this just doesn't sound like a CodeIgniter specific problem to me. Can you look in Firebug or your log info and tell us anything more?


This may be of help:

http://ellislab.com/forums/viewthread/90231/


MySQL, $query->result_array, and NginX - El Forum - 06-22-2011

[eluser]cmd276[/eluser]
I'll ask the host about the user permissions on running nginx, and mysql.

As far as I know, nginx doesn't use htaccess files. (How would this effect the SQL part? Am I not seeing a link?) I'm using the query string set up right now, and was/is fine with it that way for now. I already figured this was a nginx set up problem.

Here are logs from the CodeIgniter set up, for ALL. (Removed the Time zone setting *required* errors.) Entire file included, except for the php snip at the top.

Server Logs:
Code:
DEBUG - 2011-06-23 07:49:10 --> Config Class Initialized
DEBUG - 2011-06-23 07:49:10 --> Hooks Class Initialized
DEBUG - 2011-06-23 07:49:10 --> Utf8 Class Initialized
DEBUG - 2011-06-23 07:49:10 --> UTF-8 Support Enabled
DEBUG - 2011-06-23 07:49:10 --> URI Class Initialized
DEBUG - 2011-06-23 07:49:10 --> Router Class Initialized
DEBUG - 2011-06-23 07:49:10 --> Output Class Initialized
DEBUG - 2011-06-23 07:49:10 --> Security Class Initialized
DEBUG - 2011-06-23 07:49:10 --> Input Class Initialized
DEBUG - 2011-06-23 07:49:10 --> CRSF cookie Set
DEBUG - 2011-06-23 07:49:10 --> Global POST and COOKIE data sanitized
DEBUG - 2011-06-23 07:49:10 --> Language Class Initialized
DEBUG - 2011-06-23 07:49:10 --> Loader Class Initialized
DEBUG - 2011-06-23 07:49:10 --> Helper loaded: url_helper
DEBUG - 2011-06-23 07:49:10 --> Database Driver Class Initialized
DEBUG - 2011-06-23 07:49:10 --> Session Class Initialized
DEBUG - 2011-06-23 07:49:10 --> Helper loaded: string_helper
DEBUG - 2011-06-23 07:49:10 --> Encrypt Class Initialized
DEBUG - 2011-06-23 07:49:10 --> A session cookie was not found.
DEBUG - 2011-06-23 07:49:10 --> Session routines successfully run
DEBUG - 2011-06-23 07:49:10 --> Controller Class Initialized
DEBUG - 2011-06-23 07:49:10 --> Helper loaded: text_helper

Locahost Logs:
Code:
DEBUG - 2011-06-22 23:05:57 --> Config Class Initialized
DEBUG - 2011-06-22 23:05:57 --> Hooks Class Initialized
DEBUG - 2011-06-22 23:05:57 --> Utf8 Class Initialized
DEBUG - 2011-06-22 23:05:57 --> UTF-8 Support Enabled
DEBUG - 2011-06-22 23:05:57 --> URI Class Initialized
DEBUG - 2011-06-22 23:05:57 --> Router Class Initialized
DEBUG - 2011-06-22 23:05:57 --> Output Class Initialized
DEBUG - 2011-06-22 23:05:57 --> Security Class Initialized
DEBUG - 2011-06-22 23:05:57 --> Input Class Initialized
DEBUG - 2011-06-22 23:05:57 --> XSS Filtering completed
DEBUG - 2011-06-22 23:05:57 --> XSS Filtering completed
DEBUG - 2011-06-22 23:05:57 --> XSS Filtering completed
DEBUG - 2011-06-22 23:05:57 --> CRSF cookie Set
DEBUG - 2011-06-22 23:05:57 --> Global POST and COOKIE data sanitized
DEBUG - 2011-06-22 23:05:57 --> Language Class Initialized
DEBUG - 2011-06-22 23:05:57 --> Loader Class Initialized
DEBUG - 2011-06-22 23:05:57 --> Helper loaded: url_helper
DEBUG - 2011-06-22 23:05:57 --> Helper loaded: date_helper
DEBUG - 2011-06-22 23:05:57 --> Database Driver Class Initialized
DEBUG - 2011-06-22 23:05:57 --> Session Class Initialized
DEBUG - 2011-06-22 23:05:57 --> Helper loaded: string_helper
DEBUG - 2011-06-22 23:05:57 --> Encrypt Class Initialized
DEBUG - 2011-06-22 23:05:57 --> Session routines successfully run
DEBUG - 2011-06-22 23:05:57 --> Controller Class Initialized
DEBUG - 2011-06-22 23:05:58 --> Helper loaded: text_helper
DEBUG - 2011-06-22 23:05:58 --> Language file loaded: language/english/date_lang.php
DEBUG - 2011-06-22 23:05:58 --> File loaded: application/views/start.php
DEBUG - 2011-06-22 23:05:58 --> File loaded: application/views/head.php
DEBUG - 2011-06-22 23:05:58 --> File loaded: application/views/style.php
DEBUG - 2011-06-22 23:05:58 --> File loaded: application/views/header.php
DEBUG - 2011-06-22 23:05:58 --> Helper loaded: form_helper
DEBUG - 2011-06-22 23:05:58 --> File loaded: application/views/loginform.php
DEBUG - 2011-06-22 23:05:58 --> File loaded: application/views/content.php
DEBUG - 2011-06-22 23:05:58 --> File loaded: application/views/footer.php
DEBUG - 2011-06-22 23:05:58 --> File loaded: application/views/end.php
DEBUG - 2011-06-22 23:05:58 --> Final output sent to browser
DEBUG - 2011-06-22 23:05:58 --> Total execution time: 0.3528