Message: Undefined property: CI_Loader::$uri - codeigniter

Here is my config/upload.php code:
if($this->uri->segment(2)=='addPlace'){
$config[upload_path] = './uploads/place_pic/';
$config[allowed_types] = 'gif|jpeg|jpg|png';
}
elseif($this->uri->segment(2)=='addPack'){
$config[upload_path] = './uploads/package_pic/';
$config[allowed_types] = 'gif|jpeg|jpg|png';
}
after run my project it shows:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Loader::$uri
Filename: config/upload.php
Line Number: 2
Backtrace:
File: D:\xampp\htdocs\project_tour_city\application\config\upload.php
Line: 2
Function: _error_handler

Use as its not getting instance of class
$this->CI->uri->segment('2')

I would sugest you autoload the URI resource

You can Change Like This
You have to get ci master class
$ci =& get_instance();
// after you use $ci instead of $this
if($ci->uri->segment(2)=='addPlace'){
$config[upload_path] = './uploads/place_pic/';
$config[allowed_types] = 'gif|jpeg|jpg|png';
}
else if($ci->uri->segment(2)=='addPack'){
$config[upload_path] = './uploads/package_pic/';
$config[allowed_types] = 'gif|jpeg|jpg|png';
}

Related

$cofig [modules_locations] not loading datatable

I am using HMVC codeigniter 3. I have a folder called admin under and in that folder I have a subfolder called client. In my config file, i have set up the module path like this;
$config['modules_locations'] = array(
APPPATH.'modules/' => '../modules/',
APPPATH.'modules/admin/' => '../modules/admin/',
);
Now, the problem is, its loadig my client controller but its not loading my entites. it is showing me the following error;
> An uncaught Exception was encountered
>
> Type: Doctrine\ORM\Query\QueryException
>
> Message: [Semantical Error] line 0, col 109 near 'entities\AppClient':
> Error: Class 'entities\AppClient' is not defined.
Please help me to solve this issue..This client module works fine, if i moved it from sub module to only modules folder
solved it...Add the following function in doctorine.php
private function _recursiveDir(&$array, $directory)
{
$scanned_dir = array_diff(scandir($directory), array('..', '.'));
sort($scanned_dir);
$subModules = array(
"admin"
);
foreach ($scanned_dir as $module) {
if (is_dir($directory.$module."/models")) {
$array[] = $directory.$module."/models/doctrine/entities";
} else if (in_array($module, $subModules)) {
$this->_recursiveDir($array, $directory.$module."/");
}
}
}

Include view to view in Codeignitter

I created a tema.php page. It has header and footer in itself.
It is getting others page by it -> <?php $this->load->view($tema);?>in tema.php.
Now I create blog post detail page. It's name is yazi1.php. It's working right. Header and footer has come to page. And I get datas from database. But now it's give me 5 error. I write errors under it.
Here is my codes ->
Dersler.php (Controller)
public function yazi1($slug = NULL){
$veri['ders'] = $this->Ders_model->getir_dersS($slug);
if(empty($veri['ders'])){
show_404();
}
$veri['baslik'] = $veri['ders']['baslik'];
$beta_veri['tema'] = $this->load->view('yazi1',$veri);
$this->load->view('tema',$beta_veri);
}
Ders_model.php (Model)
public function getir_dersS($slug = FALSE){
if($slug === FALSE){
$query = $this->db->get('ders');
return $query->result_array();
}
$query = $this->db->get_where('ders',array('slug' => $slug));
return $query->row_array();
}
yazi1.php (view)
<?php echo $ders['baslik'];?>
<?php echo $ders['icerik'];?>
Routes.php ->
$route['ders/(:any)'] = 'dersler/yazi1/$1';
Errors... ->
1-
Severity: Warning
Message: pathinfo() expects parameter 1 to be string, object given
Filename: core/Loader.php
Line Number: 900
Backtrace:
File: C:\xampp\htdocs\1koddenizi\application\views\tema.php
Line: 63
Function: view
File: C:\xampp\htdocs\1koddenizi\application\controllers\Dersler.php
Line: 19
Function: view
File: C:\xampp\htdocs\1koddenizi\index.php
Line: 315
Function: require_once
2-
Severity: 4096
Message: Object of class CI_Loader could not be converted to string
Filename: core/Loader.php
Line Number: 905
Backtrace:
File: C:\xampp\htdocs\1koddenizi\application\views\tema.php
Line: 63
Function: view
File: C:\xampp\htdocs\1koddenizi\application\controllers\Dersler.php
Line: 19
Function: view
File: C:\xampp\htdocs\1koddenizi\index.php
Line: 315
Function: require_once
3-
Severity: 4096
Message: Object of class CI_Loader could not be converted to string
Filename: core/Loader.php
Line Number: 907
Backtrace:
File: C:\xampp\htdocs\1koddenizi\application\views\tema.php
Line: 63
Function: view
File: C:\xampp\htdocs\1koddenizi\application\controllers\Dersler.php
Line: 19
Function: view
File: C:\xampp\htdocs\1koddenizi\index.php
Line: 315
Function: require_once
4-
Severity: Warning
Message: include(C:\xampp\htdocs\1koddenizi\application\views): failed to open stream: Permission denied
Filename: core/Loader.php
Line Number: 968
Backtrace:
File: C:\xampp\htdocs\1koddenizi\application\views\tema.php
Line: 63
Function: view
File: C:\xampp\htdocs\1koddenizi\application\controllers\Dersler.php
Line: 19
Function: view
File: C:\xampp\htdocs\1koddenizi\index.php
Line: 315
Function: require_once
5-
Severity: Warning
Message: include(): Failed opening 'C:\xampp\htdocs\1koddenizi\application\views\' for inclusion (include_path='C:\xampp\php\PEAR')
Filename: core/Loader.php
Line Number: 968
Backtrace:
File: C:\xampp\htdocs\1koddenizi\application\views\tema.php
Line: 63
Function: view
File: C:\xampp\htdocs\1koddenizi\application\controllers\Dersler.php
Line: 19
Function: view
File: C:\xampp\htdocs\1koddenizi\index.php
Line: 315
Function: require_once
You could set a TRUE flag when nesting a view to another view, so it will return the content rather than display it :
$beta_veri['tema'] = $this->load->view('yazi1', $veri, TRUE);
$this->load->view('tema', $beta_veri);

Shopware installation error: Identifier DB not initialized yet

After installation wizard is finished I get this error.
Slim Application Error
The application could not run because of the following error:
Details
Type: RuntimeException
Message: Identifier DB not initialized yet
File: /.../recovery/install/src/ContainerProvider.php
Line: 162
Is there is some configuration file where I can set DB params? I had insert all params via installation wizard.
In file recovery/install/src/ContainerProvider.php
Add 2 strings:
In use-section
use Shopware\Recovery\Update\Utils;
2.Inside the register-function:
$container['db'] = function ($c) {
$conn = Utils::getConnection(SW_PATH);
return $conn;
};

CodeIgniter run library before database settings

I test my Codeigniter site on localhost then update it on a server. Switching between them involves a lot of adjustment-related problems.
So I want to config it by only one constant: MYCUSTOM_SERVER_LOCATION
Then my database connection and password is configured according to location of my server(localhost or myhost). The only problem is that database.php is run before mysettings library. Even doing settings in a config file instead of a library has the same result.
[UPDATED]
application/config/autoload.php:
...
$autoload['libraries'] = array('mysettings','database','session');
...
application/libraries/mysettings.php:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
define("MYCUSTOM_SERVER_LOCATION", "localhost");
class mysettings {
//////////////////////////////////////////////////
// option: localhost
// option: 000webhost
//$config["mycustom_server"]="localhost";
}
application/config/database.php
if(MYCUSTOM_SERVER_LOCATION=="localhost")
{
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = '...';
$db['default']['password'] = '...';
$db['default']['database'] = '...';
}
else if(MYCUSTOM_SERVER_LOCATION=="myserver")
{
$db['default']['hostname'] = '...';
$db['default']['username'] = '...';
$db['default']['password'] = '...';
$db['default']['database'] = '...';
}
else
{
echo "Unknown server.";
}
output result:
A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant MYCUSTOM_SERVER_LOCATION - assumed 'MYCUSTOM_SERVER_LOCATION'
Filename: config/database.php
Line Number: 51
A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant MYCUSTOM_SERVER_LOCATION - assumed 'MYCUSTOM_SERVER_LOCATION'
Filename: config/database.php
Line Number: 58
Unknown server.
You can set the $active_group variable in application/config/database.php
Example Usage:
/*
The $active_group variable lets you choose which connection group to
make active. By default there is only one group (the 'default' group).
*/
$active_group = "development";
$db['development']['hostname'] = "localhost";
$db['development']['username'] = "us";
$db['development']['password'] = "";
$db['development']['database'] = "db1";

NuSOAP on XAMPP with PHP5: failed to open stream

Hey guys, I have a problem (again). This time I am trying to use NuSoap w/ XAMPP 1.7.1 which includes PHP5 and MySQL ... I wrote a soap-client:
<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/mysql/helloworld2.php');
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo '<p><b>Constructor error: ' . $err . '</b></p>';
// At this point, you know the call that follows will fail
}
// Call the SOAP method
$result = $client->call('hello', array('name' => 'Doro'));
// Check for a fault
if ($client->fault) {
echo '<p><b>Fault: ';
print_r($result);
echo '</b></p>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<p><b>Error: ' . $err . '</b></p>';
} else {
// Display the result
print_r($result);
}
}
?>
and my soap-server:
// Enable debugging *before* creating server instance
$debug = 1;
// Create the server instance
$server = new soap_server;
// Register the method to expose
$server->register('hello');
// Define the method as a PHP function
function hello($name) {
$dbhost = 'blah';
$dbuser = 'blub';
$dbpass = 'booboo';
try{
$conn = MYSQL_CONNECT($dbhost, $dbuser, $dbpass)
or die ('Error connecting to mysql');
if( !$conn ){
return 'Hello, '.$name.' ... too bad, I cannot connect to the db!';
}
else{
$dbname = 'soaperina';
MYSQL_SELECT_DB($dbname) or die('Error connecting to '.dbname);
$queryres = #mysql_db_query(
'response',
'SELECT * FROM farben');
return 'RESPONSE: <br>';
while( $arr = mysql_fetch_array( $queryres ) ){
return $arr["ID"]." - ".$arr["Farben"]." - ".$arr["Rating"]."<br>";
}
}
}
catch(Exception $e){
return 'Sorry, '.$name.', but that did not work at all!';
}
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
I know that PHP works, the Apache works, MySQL works ... it also works together, but when I try to make it work with NuSOAP it does not work. I get following:
Warning:
SoapClient::SoapClient(http://localhost/mysql/helloworld2.php)
[soapclient.soapclient]: failed to
open stream: Ein Verbindungsversuch
ist fehlgeschlagen, da die Gegenstelle
nach einer bestimmten Zeitspanne nicht
richtig reagiert hat, oder die
hergestellte Verbindung war
fehlerhaft, da der verbundene Host
nicht reagiert hat. in
C:\xampp\htdocs\mysql\helloworld2client.php
on line 6
Warning: SoapClient::SoapClient()
[soapclient.soapclient]: I/O warning :
failed to load external entity
"http://localhost/mysql/helloworld2.php"
in
C:\xampp\htdocs\mysql\helloworld2client.php
on line 6
Fatal error: Maximum execution time of
60 seconds exceeded in
C:\xampp\htdocs\mysql\helloworld2client.php
on line 41
I have no idea what that is supposed to mean. I hope ya'll can help!!! Thnx in advance :)
I used NuSOAP version 1.7.3 with PHP5. In this NuSOAP 1.7.3, soapclient class renamed by nu_soapclient.
You can try this:
$client = new nusoap_client('http://localhost/mysql/helloworld2.php');
to give an answer to my own question: nusoap has a problem with php5 ... there are some answers and some solutions on the net (not many), but they didn't work with me. I downgraded to php4 and it works fine ...

Resources