I am trying to take db backup in codeigniter using function dbutil. It is working fine in local but in live server i am getting some php error. Please help me where i did wrong.
below is my code and error
Controller
function db_backup()
{
$this->load->dbutil();
$prefs = array(
'format' => 'zip',
'filename' => 'industry_speak.sql'
);
$backup =& $this->dbutil->backup($prefs);
$db_name = 'is-backup-on-'. date("Y-m-d-H-i-s") .'.zip';
$save = './assets/db_backup/'.$db_name;
$this->load->helper('file');
write_file($save, $backup);
$this->load->helper('download');
force_download($db_name, $backup);
}
Error
In line No. 3775 below code is present.
$backup =& $this->dbutil->backup($prefs);
A PHP Error was encountered
Severity: Runtime Notice
Message: Only variables should be assigned by reference
Filename: controllers/Admin.php
Line Number: 3775
Backtrace:
File: /home/acetronsma/public_html/application/controllers/Admin.php
Line: 3775 Function: _error_handler
File: /home/acetronsma/public_html/index.php Line: 316 Function:
require_once
$backup = $this->dbutil->backup($prefs);
remove =&,
cm
Related
why ??
A PHP Error was encountered Severity: Notice
Message: Undefined property: stdClass::$users
Filename: views/user_view.php
Line Number: 10
Backtrace:
File: C:\xampp\htdocs\ci\application\views\user_view.php Line: 10
Function: _error_handler
File: C:\xampp\htdocs\ci\application\controllers\users.php Line: 7
Function: view
File: C:\xampp\htdocs\ci\index.php Line: 315 Function: require_once
You try to access a variable without it first being defined. If you define it first, you won't get an error.
<?php
$x = new stdClass();
$y = $x->z; // gererates Notice in error_log
$x = new stdClass();
$x->z = 'assigned'; // now it is assigned
$y = $x->z; // no error
// or you could make your own class
class Whatever
{
public $z;
}
$x = new Whatever();
$y = $x->z; // it's there whether a value has been assigned or not
Check it out here https://3v4l.org/hOThV
I got this error trying to access our SCADA website:
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 341
I scanned into the Loader.php file and on line 341 found this code:
$CI->db =& DB($params, $active_record);
This is the complete block with the error code:
public function database($params = '', $return = FALSE, $active_record = NULL)
{
// Grab the super object
$CI =& get_instance();
// Do we even need to load the database class?
if (class_exists('CI_DB') AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db))
{
return FALSE;
}
require_once(BASEPATH.'database/DB.php');
if ($return === TRUE)
{
return DB($params, $active_record);
}
// Initialize the db variable. Needed to prevent
// reference errors with some configurations
$CI->db = '';
// Load the DB class
$CI->db =& DB($params, $active_record);
}
The file you mention is just where the call happened when the issue happened.
The real issue is either:
Your settings in application/configuration/database.php
or
Your Database server is down, inaccessible or the credentials have changed
i have method for uploading image, but i get multiple error messages if i run this method with error:
Severity: Warning
Message: pathinfo() expects parameter 1 to be string, array given
Filename: core/Loader.php
Line Number: 759
Severity: Notice
Message: Array to string conversion
Filename: core/Loader.php
Line Number: 760
An Error Was Encountered
Unable to load the requested file: Array.php
how do I fix the code so as not to get an error ? where is the problem ?
thanks
function upload_image()
{
$config = array(
'file_name'=> 'hallo.jpg',
'upload_path'=>'./application/views/photo',
'allowed_types'=>'gif|jpg|png',
'max_size'=>'1024',
'max_width'=>'1600',
'max_height'=>'1200'
);
$this->load->library('upload', $config);
if($this->upload->do_upload())
{
$data['breadcrumb1'] = "Member";
$data['breadcrumb'] = "Add Member";
$data['content']='admin-cms/member/add';
$this->load->view('admin-cms/index', $data);
}else
{
$data['content']= array('error' => $this->upload->display_errors('<span class="error">','</span>'));
$this->load->view('admin-cms/index', $data);
}
}
I have this code in a file named server.class.php:
class server
{
function addPlayer($player)
{
//Stuff
}
}
Then, I have this in a file called send.php. These are lines 38-40:
require('/var/www/server/apply/server.class.php');
$server = new server;
$server->addPlayer($_POST['IGN']);
However, I get this error when I visit my page (Php.ini is set to show all errors):
Fatal error: Class 'server' not found in /var/www/server/apply/send.php on line 39
Line 39 is $server = new server;
What am I doing wrong? I have verified that the class file is in /var/www/server/apply/server.class.php.
$server = new server()
Missed the brackets
Hi i am trying to import the configuration variables from a config file that i had created
Config.php has
class Config
{
public $SERVERNAME = '*******';
public $SUSERNAME = '*********';
public $SPASSWORD = '*********';
public $DBNAME2 = '********';
}
for importing this variable in another file i tried
include('./Config.php') or die("error");
$cnfig = new Config();
But when i try to use $cnfig->DBNAME2 its not working
Please help to sole this problem.
Thank you.
EDIT
It was working in localsystem , when i tied to upload through web hosting it was not working.
Try below one
include ('./Config.php');
$cnfig = new Config();
echo "<pre>";print_r($cnfig);
Edit:
I am getting below output so it should be working for you too.
Config Object
(
[SERVERNAME] => *******
[SUSERNAME] => *********
[SPASSWORD] => *********
[DBNAME2] => ********
)
Edit:2
You can also do like this
(include('./Config.php')) or die("error");
$cnfig = new Config();
echo "<pre>";print_r($cnfig);
http://www.php.net/manual/en/function.include.php#39043
or has higher priority than include()
Error Ouput:
When only use include('./Config.php') or die("error"); it's giving below error.
Warning: include(1) [function.include]: failed to open stream: No such file or directory in D:\path_to_file\myConfig.php on line 2
Warning: include() [function.include]: Failed opening '1' for inclusion (include_path='.;D:\ZendServer\share\ZendFramework\library') in D:\path_to_file\myConfig.php on line 2
Fatal error: Class 'Config' not found in D:\path_to_file\myConfig.php on line 6