CodeIgniter Forums
[solved] No echo at command line, but echo in browser - 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: [solved] No echo at command line, but echo in browser (/showthread.php?tid=51683)



[solved] No echo at command line, but echo in browser - El Forum - 05-13-2012

[eluser]SPeed_FANat1c[/eluser]
Hello,

could you tell ideas where to search for problem if there is no echo from command line when I run the function, but it echos text when I run in browser?

How to debug that?

I can tell I tried echoing string before class, and it was echoed in console. So the file is accessed. It looks like the function is not executed, not even constructor.

What could cause not executing constructor when from command line?


Edit:

it has something to do with session, because I checked log file, when its empty, I run from cmd and it generates this:


DEBUG - 2012-05-14 09:23:29 --> Config Class Initialized
DEBUG - 2012-05-14 09:23:29 --> Hooks Class Initialized
DEBUG - 2012-05-14 09:23:29 --> Utf8 Class Initialized
DEBUG - 2012-05-14 09:23:29 --> UTF-8 Support Enabled
DEBUG - 2012-05-14 09:23:29 --> URI Class Initialized
DEBUG - 2012-05-14 09:23:29 --> Router Class Initialized
DEBUG - 2012-05-14 09:23:29 --> Output Class Initialized
DEBUG - 2012-05-14 09:23:29 --> Security Class Initialized
DEBUG - 2012-05-14 09:23:29 --> Input Class Initialized
DEBUG - 2012-05-14 09:23:29 --> Global POST and COOKIE data sanitized
DEBUG - 2012-05-14 09:23:29 --> Language Class Initialized
DEBUG - 2012-05-14 09:23:29 --> Loader Class Initialized
DEBUG - 2012-05-14 09:23:29 --> Helper loaded: url_helper
DEBUG - 2012-05-14 09:23:29 --> Helper loaded: form_helper
DEBUG - 2012-05-14 09:23:29 --> Helper loaded: html_helper
DEBUG - 2012-05-14 09:23:29 --> Helper loaded: cookie_helper
DEBUG - 2012-05-14 09:23:29 --> Helper loaded: language_helper
DEBUG - 2012-05-14 09:23:29 --> Helper loaded: isajax_helper
DEBUG - 2012-05-14 09:23:29 --> Language file loaded: language/english/english_lang.php
DEBUG - 2012-05-14 09:23:29 --> Database Driver Class Initialized


But when I run from browser, it generates previous, plus these lines:

DEBUG - 2012-05-14 09:24:59 --> Session Class Initialized
DEBUG - 2012-05-14 09:24:59 --> Helper loaded: string_helper
DEBUG - 2012-05-14 09:24:59 --> Session routines successfully run
DEBUG - 2012-05-14 09:24:59 --> Form Validation Class Initialized
DEBUG - 2012-05-14 09:24:59 --> Model Class Initialized
DEBUG - 2012-05-14 09:24:59 --> Model Class Initialized
DEBUG - 2012-05-14 09:24:59 --> Model Class Initialized
DEBUG - 2012-05-14 09:24:59 --> Model Class Initialized
DEBUG - 2012-05-14 09:24:59 --> Model Class Initialized
DEBUG - 2012-05-14 09:24:59 --> Model Class Initialized
DEBUG - 2012-05-14 09:24:59 --> Model Class Initialized
DEBUG - 2012-05-14 09:24:59 --> Controller Class Initialized
DEBUG - 2012-05-14 09:24:59 --> Final output sent to browser
DEBUG - 2012-05-14 09:24:59 --> Total execution time: 0.1054



EDIT2:

tried removing thing from autoload.php file, and found out that when I revovo database from
$autoload['libraries']

then it works and eches strign from controller function.

The database is postgresql. Can this have something to do with command line? Since the default database is mysql for codeigniter.


EDIT3:

just tried with fresh CI 2.0.3 and same database connection settings and it also failed to load from cmd. Clearly something is wrong with database.

And the same is with CI 2.1.0

EDIT4:

created empty test postgre database and made this function:

Code:
echo 'test 2.1.0';
  $sql = "select now() as n";
  $query = $this->db->query($sql);
  $row = $query->row_array();

  echo $row['n'];

and it works. So now interesting what could be the difference from real project database.

EDIT5: made mistake - i connected to default mysql database so it worked. With postgre even test db it does not work


Edit6:

the problem was the function in postgre_driver.php

Code:
function db_pconnect()
{
  return @pg_pconnect($this->_connect_string());
}

it did not connect but did not show any errors and stopped then. I found that I need to enable

extension=pgsql.dll ; For Windows

http://bytes.com/topic/apache/answers/835863-fatal-error-call-undefined-function-pg_connect

not only in apache folder php.ini file, but also in php folder.

When I removed that @ char I saw the error in console.