Undefined Variable Errors - zend-studio

I receive a lot of undefined variable errors in zend studio 10.
I have a php file like this :
file var.php
<?php
$functions = $root."/requires/functions.php";
$top_utf = $root."/requires/top_utf.php" ;
$database = $root."/requires/db.php" ;
$footer = $root."/requires/pageFooter.php" ;
?>
Now if I use the following code in a php file, zend studio shows Undefined Variable errors on all the require_once lines. (If I access this page with a browser the page is displayed as expected and it works perfectly.)
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
require_once($root."/requires/vars.php") ;
require_once($functions);
require_once($top_utf);
require_once($database);
require_once($footer);
?>
Doesn't Zend Studio recognize the declared variables in an included file (var.php in this case)?
Since $functions and $top_utf variables are defined in var.php, I believe I shouldn't receive these errors.
Any kind of advice is much appreciated.

If you're going to use this style of programming, which I'm not advocating, I suggest you define constants in your var.php instead

Related

codeigniter array session issue after move site one server(godaddy) to another server(bluehost)

There is issue in session. This is my array.
print_r($this->session->userdata("user_data"));
Array
(
[useremail] => myid#gmail.com
[user_id] => 1
[is_login] => 1
)
I want to get the useremail . so I am writing this code.
print_r($this->session->userdata("user_data")['useremail']);
It gives the error . Parse error: syntax error, unexpected '['
If I am writing the code like this :
$dataval = $this->session->userdata("user_data");
print_r($dataval['useremail']);
Then it it working fine .
Please help me what is issue ?
It is because you (probably) moved from newer php version (5.4+) to older version (5.2).
Accessing array items directly by calling function name is only available on php 5.4 and newer: array dereferencing.
Only solution is to use temporary variable (like your $dataval). Or you can switch to newere php version, if the bluehost allows it.

Wrong controller function getting called

I'm building a small HR management system for my company, and am facing a weird issue with GoDaddy hosting. As if the pain that comes with figuring out the index.php? part was not enough, now I'm not able to log in as an HR. The error I get is that:
Parse error: syntax error, unexpected '[' in /home/content/37/11019837/html/hrms/application/controllers/hr.php on line 58
Now the line it refers to is part of a file upload function, and goes like this:
$path = $this->upload->data()['full_path'];
. . . which is simply saving the uploaded file path to $path. BUT, this is part of the uploading function and shouldn't even be accessed while logging in. Once I hit "Log in", the URL says http://www.example.com/hrms/index.php?/hr/dashboard which means the following function will be called:
public function dashboard()
{
$data['page_title'] = 'HR Area';
$this->load->view('hr/header.php', $data);
$this->load->view('hr/navigation.php');
$this->load->view('hr/footer.php');
}
A parting note: The app is working without hiccups on the local server, so I'm not sure why it's hopping functions on GoDaddy servers. Can someone throw some light?
Try this:
$path = $this->upload->data();
$path1 = $path['full_path'];

Mangeto how to get session subtotal value?

I am currently using magento 1.9.1 and i'm trying to get the session subtotal value in external file.
So here it is the code that i am working around with:
<?PHP
require('app/Mage.php'); //Path to Magento
Mage::app();
echo Mage::getSingleton('checkout/session')->getQuote()->getSubtotal();
?>
The problem is that when i execute this script i receive blank screen. No value is displayed.
This is all the code in this php page.
What i am doing wrong, can you help me ?
Thanks!
Try
<?php echo Mage::helper('checkout/cart')->getQuote()->getSubtotal() ?>
To see whats behind the white screen:
Goto index.php and uncomment the following line:
#ini_set('display_errors', 1);

how to read yii session in codeginiter controller. I am new to both the frameworks

Following is the code I have used :-
require(realpath(dirname(__FILE__).'/../../../email/apps/common/framework/YiiBase.php'));
$config = require(realpath(dirname(__FILE__).'/../../../email/apps/customer/config/main.php'));
Yii::createWebApplication($config);
var_dump(Yii::app()->User->id);
i am getting following error:-
Message: include(): Failed opening 'Yii.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear')
Filename: framework/YiiBase.php
Line Number: 428
Be kind write full absolute path for the script that executes the code and location of the files YiiBase.php and main.php.
Solution from the creator of Yii says:
require_once('path/to/yii.php');
Yii::createWebApplication($config);
// you can access Yii::app() now as usual
$session = Yii::app()->session;
//....use session as you wish
My file that can help you start is:
// change the following paths if necessary
$yii=dirname(__FILE__).'/../yii/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
require_once($yii);
Yii::createWebApplication($config);
NOTE
Its is not recommended you use YiiBase. Use either yii or yiilite. YiiBase serves as base class and is not intended to be used directly (to the best of my kowledge). Also check paths if they real point to the file!

Write permissions with Codeigniter + Simplepie

I am trying to create a simple RSS parser using the two frameworks. However I am getting PHPerrors when trying to write to my cache directory:
set_cache_location(APPPATH.'cache/rss');
I am running windows 7 with XAMPP using the latest version of Simplepie from github
error:
A PHP Error was encountered
Severity: User Warning
Message: C:\xampp\htdocs\geekurls/system/application/cache/rss is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.
Filename: libraries/simplepie.php
Line Number: 1732
Tried like the below comment said and tried making a test file but to no luck
$file = APPPATH."cache/rss/testFile.txt";
$handle = fopen($file, 'w') or die("fail");
fclose($handle);
A simple checks to find out what might be happening,
Try creating a file in this directory using standard php - this could help solve permission problems.
$this->load->helper('file');
$data = 'Some file data';
if ( ! write_file('./path/to/file.php', $data))
{
echo 'Unable to write the file';
}
else
{
echo 'File written!';
}
Also how about using the default cache?
http://simplepie.org/wiki/faq/i_m_getting_cache_error_messages

Resources