• 11
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I m trying to run php file from the command fine. here files are not included. Whrn I run php script from the browser its works perfect but when I run it from cmd then its giving error for that included file

PHP code

require("include/config.php");
include_once('include/classes/dbclass.php');
include_once('include/classes/send_emails.php');

Here suppose I put the code of dbclass.php file into main one and removed include_once('include/classes/dbclass.php'); line than there is no problem. So how to write include path or set include file when we used cmd to run php script

Your setup may have different php.ini option files for cmdline and web use, you can either add the right include_path to the cmdline ini file (/etc/php5/cli/php.ini in my case), or pass it as a command line parameter:

php -d include_path=... script.php
  • 9
Reply Report

I like doing:

require dirname(__FILE__) . '/../include/file.php';

That way all includes and requires are relative to the local file.

Also, require, etc are not functions. You should not use parenthesis.

  • 8
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions