include_path won't work on PhpStorm - php

I have a construct function where I am using include_path, the function looks like this :
public function __construct()
{
$url = $this->parseUrl();
if(file_exists('application\controllers'.$url[0].'.php')){
$this->controller=$url[0];
unset($url[0]);
}
require_once 'application\controllers'.$this->controller.'.php';
echo $this->controller;
}
Unfortunately, when I try to load an existing controller url like this one http://localhost/project/public_html/home I get the following error :
Warning: require_once(application\controllers home.php): failed to open stream: No such file or directory in C:\xampp\htdocs\project\application\core\App.php on line 24
Fatal error: require_once(): Failed opening required 'application\controllers home.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\project\application\core\App.php on line 24
I followed the documentation and I included the paths :
C:\xampp\htdocs\project\application
and
C:\xampp\htdocs\project\application\controllers
but I am still getting the error and I am just clueless why... can someone help me?

But you have a space in the path...is that normal?
Can you try with 'application\controllers' (without space there) please?
And controllershome.php is the name of file, or controllers/home.php?

Related

Warning: move_uploaded_file(): The second argument to copy() function

I'm working on a file upload method. But i suddenly start to get the following error, The only thing I changed was the file name. I reverted it back, but the error still persists.
Does anyone know how to solve this?
The error message is:
Warning: move_uploaded_file(): The second argument to copy()
function cannot be a directory in
/hermes/bosnaweb14a/b1717/ipg.plantationkeyartcorn/kittyrescuetnr/docs/upload.php
on line 13
Warning: move_uploaded_file(): Unable to move '/tmp/phpJki8OC' to '/' in
/hermes/bosnaweb14a/b1717/ipg.plantationkeyartcorn/kittyrescuetnr/docs/upload.php
on line 13
Fail
my php looks like this
<?php
$file_upload="true";
$file_up_size=$_FILES['file_up'][size];
$file_destination=$REQUEST['file_type'];
$file_new_name=$REQUEST['file_name'];
$file_name=$_FILES[file_up][name];
**$add="$file_destination/$file_new_name"; // the path with the file name where the file will be stored**
if($file_upload=="true"){
if(move_uploaded_file ($_FILES[file_up][tmp_name], $add)){
echo print_r($file_new_name);
}else{echo "Fail";}
}else{
echo $msg;
}
?>
Well, since you are using superglobal array $_REQUEST incorrectly (notice the underscore in the name), your $add variable evaluates to just a slash. Which is a root directory.
Hence the errors - it is a directory after all and your script probably don't have write access to it anyway (which is a good thing).

Fatal Error- Require_once

I am getting the following error:
Warning: require_once(C:\xampp\htdocs\mvc\public\views\home\init.php): failed to open stream: No such file or directory in C:\xampp\htdocs\mvc\public\index.php on line 3
Fatal error: require_once(): Failed opening required 'C:\xampp\htdocs\mvc\public\views\home\init.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\mvc\public\index.php on line 3
In Index.php, my code is
<?php
require_once __DIR__ . '\views\home\init.php';
$app= new app;
?>
In init.php, my code is
<?php require_once __DIR__ . '\core\app.php';
require_once __DIR__ . '\core\controller.php';
In controller.php:
<?php
class controller
{
}
?>
In app.php
<?php
class app
{
public function _construct()
{
echo 'now what';
}
}
?>
My folder paths are:
htdocs\mvc\app\views\home\init.php
htdocs\mvc\app\core\app.php & controller.php
htdocs\mvc\public\index.php
Anybody please help? i have tried require_once (_DIR . ""); as well but not working.
Try this:
First do echo for the file path in index.php file like -
echo __DIR__ . '/views/home/init.php';
And then check whether the path is correct or not. If not, then change it accordingly and then use the path in require_once.
You can also test the permission of directory and file itself. There could be an issue of executing file if permission is read only.
restore the index.php file in your public folder.... the error will clear out.
Put index.php file in your public folder.... the error will clear out.
tested and verified

mkdir() throws warning message

What's the error in here?
<?php
define('TMP_FOLDER','temp');
$temp_dir = $this->dir['root'].$this->config['sep'].TMP_FOLDER;
//$temp_dir = C:\xampp\htdocs\xxx\temp
//$this->dir['root'] = C:\xampp\htdocs\xxx
if(!file_exists($temp_dir) && !is_dir($temp_dir)){
chdir('../');
mkdir(TMP_FOLDER, 0744);
}
?>
This throws a warning like:-
Warning: mkdir(): File exists in C:\xampp\htdocs\xxx\yyy\display.php on line 49
I think this is an easy job. But, I can't understand what's this?
remove below line and try
chdir('../');
Found it, I removed the line
chdir('../');
changing the directory, directed to c:\xampp\htdocs. Removing this solved the problem.

XAMPP Path to include in PHP and AJAX

After reading tons of articles and trying out a lot code I coudn't make it work to include a php file form my localhost. And know I cannot even specify a path in javascript code like
xmlhttp.open("GET","/DB/ajax/ajaxDeleteRow.php?q="+commentId,true);
I would like to include the file: drawTableSqlString.php which is in the same folder as my file: CommentTableAndDeleteAjax.php. they are in the folder: C:\xampp\htdocs\DB\ajax
What I tried so far:
1.
echo get_include_path(); and i got displayed: .;C:\xampp\php\PEAR
then I tried to copy my file into that folder --> didn't work.
echo dirname(drawTableSqlString.php);
I got an error:
Notice: Use of undefined constant drawTableSqlString - assumed 'drawTableSqlString' in C:\xampp\htdocs\DB\ajax\CommentTableAndDeleteAjax.php on line 36
3.
after changing path in php.ini from "include_path=".;C:\xampp\htdocs"" to include_path=".;C:\xampp\php\PEAR"
i tried:
include ('\DB\ajax\drawTableSqlString.php');
include ('DB\ajax\drawTableSqlString.php');
gives an error as aways which looks like this:
Warning: include(\DB\ajax\drawTableSqlString.php): failed to open
stream: No such file or directory in
C:\xampp\htdocs\DB\ajax\CommentTableAndDeleteAjax.php on line 33
Warning: include(): Failed opening '\DB\ajax\drawTableSqlString.php'
for inclusion (include_path='.;C:\xampp\htdocs') in
C:\xampp\htdocs\DB\ajax\CommentTableAndDeleteAjax.php on line 33
Based on other forum entries I also tried all that code below but nothing worked:
//************************** include DB connection INFOS
//$xajax_dir = 'C:\\xampp\\htdocs\\DB\\ajax';
//include( $xajax_dir . DIRECTORY_SEPARATOR . 'drawTableSqlString.php' );
//include('./localhost/DB/ajax/CommentTableAndDeleteAjax.php' );
//include('localhost/DB/ajax/CommentTableAndDeleteAjax.php' );
//include('./DB/ajax/CommentTableAndDeleteAjax.php' );
//include('DB/ajax/CommentTableAndDeleteAjax.php' );
//include('C:/xampp/htdocs/localhost/DB/ajax/drawTableSqlString.php' );
//include_path = ('.;C:\xampp\php\PEAR','C:\xampp\htdocs\DB\ajax\drawTableSqlString.php');
//include('127.0.0.1/DB/ajax/CommentTableAndDeleteAjax.php' );
//include('C:\xampp\htdocs\DB\ajax\drawTableSqlString.php');
//FROM http://stackoverflow.com/questions/17003614/including-files-from-include-path-not-working-as-expected
//include_once ('/DB/ajax/drawTableSqlString');
//include_once("C:/xampp/htdocs/DB/ajax/drawTableSqlString.php");
// include __DIR__ . 'drawTableSqlString.php';
// include '../drawTableSqlString.php';
//include('http://127.0.0.1/DB/ajax/CommentTableAndDeleteAjax.php' );
//$xajax_dir = 'C:\\xampp\\htdocs\\DB\\ajax';
//include( $xajax_dir . DIRECTORY_SEPARATOR . 'drawTableSqlString.php' );
//include ('drawTableSqlString.php');
//include_path=".;c:\php\includes"
//http://www.php.net/manual/en/ini.core.php#ini.include-path
//set_include_path(".;c:\xampp\htdocs\DB\ajax");
//include ('drawTableSqlString.php');
//echo get_include_path();
Any help would be really apreciated.
EDIT:
Since I changed some parts of the php.ini I get an error when staring XAMPP saying:
Fatal Error: Directive 'register_globals' is no longer available in
PHP

Fetch data using phpquery

i have to fetch data from web page using phpquery and i have already used a example
this following is the code...
<?php
require_once(dirname(__FILE__) . "/phpQuery.php");
phpQuery::browserGet('http://www.google.com/', 'success1');
function success1($browser) {
$browser
->WebBrowser('success2')
->find('input[name=q]')
->val('search phrase')
->parents('form')
->submit();
}
function success2($browser) {
print $browser;
}
and right now i have a new error that is
Warning: require_once(WebBrowser.php): failed to open stream: No such file or directory in /var/www/TantraProjects/phpQuery/phpQuery.php on line 4922 Fatal error: require_once(): Failed opening required 'WebBrowser.php' (include_path='.:/usr/share/php:/usr/share/pear:/var/www/TantraProjects/phpQuery/phpQuery/:/var/www/TantraProjects/phpQuery/phpQuery/plugins/') in /var/www/TantraProjects/phpQuery/phpQuery.php on line 4922
i cant understand why this is shown , help me...
most obviously you don't have phpQuery.php in the same directory as you script - mind you: On a Linux webhost filenames are case-sensitive.
It's an additional file that needs to be available for reading.
The phpQuery WebBroswer is a plugin. Check that you have put that file (WebBrowser.php) into the location it gives you the error and that it's available to be read, e.g.
/var/www/TantraProjects/phpQuery/WebBroswer.php

Categories