I am using phpMYADMIN and netbeans for coding, when pressing run project in netbeans at the top of my page I get this error: `
Warning: include(utils/mysql.class.php): failed to open stream: No such file or directory in C:\xampp1\htdocs\autonuoma\index.php on line 6
Warning: include(): Failed opening 'utils/mysql.class.php' for inclusion (include_path='C:\xampp1\php\PEAR') in C:\xampp1\htdocs\autonuoma\index.php on line 6
My whole is index.php is:
<?php
// nuskaitome konfigūracijų failą
include 'config.php';
// iškviečiame prisijungimo prie duomenų bazės klasę
include 'utils/mysql.class.php';
// nustatome pasirinktą modulį
$module = '';
if(isset($_GET['module'])) {
$module = mysql::escape($_GET['module']);
}
// jeigu pasirinktas elementas (sutartis, automobilis ir kt.), nustatome elemento id
$id = '';
if(isset($_GET['id'])) {
$id = mysql::escape($_GET['id']);
}
// nustatome, kokia funkcija kviečiama
$action = '';
if(isset($_GET['action'])) {
$action = mysql::escape($_GET['action']);
}
// nustatome elementų sąrašo puslapio numerį
$pageId = 1;
if(!empty($_GET['page'])) {
$pageId = mysql::escape($_GET['page']);
}
// nustatome, kurį valdiklį įtraukti šablone main.tpl.php
$actionFile = "";
if(!empty($module) && !empty($action)) {
$actionFile = "controls/{$module}_{$action}.php";
}
// įtraukiame pagrindinį šabloną
include 'templates/main.tpl.php';
?>
When I click some menu option in the webpage it returns an error also:
Warning: include(utils/mysql.class.php): failed to open stream: No such file or directory in C:\xampp1\htdocs\autonuoma\index.php on line 6
Warning: include(): Failed opening 'utils/mysql.class.php' for inclusion (include_path='C:\xampp1\php\PEAR') in C:\xampp1\htdocs\autonuoma\index.php on line 6
Fatal error: Uncaught Error: Class 'mysql' not found in C:\xampp1\htdocs\autonuoma\index.php:11 Stack trace: #0 {main} thrown in C:\xampp1\htdocs\autonuoma\index.php on line 11
My question is, what is causing this? The webpage is loading, but it doesn't let me click anything since mentioned error occurs. I know this might sound very silly but I cannot locate the error
`
Related
I need help with these few errors here
`[06-May-2018 20:08:16 America/New_York] PHP Warning: include_once(unifont/ttfonts.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/squid/lib/tfpdf.php on line 507
[06-May-2018 20:08:16 America/New_York] PHP Warning: include_once(): Failed opening 'unifont/ttfonts.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.4.45/lib/php') in /Applications/MAMP/htdocs/squid/lib/tfpdf.php on line 507
[06-May-2018 20:08:16 America/New_York] PHP Fatal error: Class 'TTFontFile' not found in /Applications/MAMP/htdocs/squid/lib/tfpdf.php on line 508`
This is the line 507:
if (!isset($type) || $type != "TrueTypesubset") {
include_once($this->_getfontpath().'unifont/ttfonts.php');
line 507>>> $ttf = new TTFontFile();
And this is line 508
$ttf = new TTFontFile();
I updated the paths to this :
if ($uni) {
if (defined("_SYSTEM_TTFONTS") && file_exists(_SYSTEM_TTFONTS.$file )) { $ttfilename = _SYSTEM_TTFONTS.$file ; }
else { $ttfilename = $this->_getfontpath().'/Applications/MAMP/htdocs/squid/lib/font/unifont/'.$file ; }
$filename = $file;
$filename =str_replace(' ','',$filename );
$filename =str_replace('-','',$filename );
$unifilename = $this->_getfontpath().'unifont/'.strtolower(substr($filename ,0,(strpos($filename ,'.'))));
$diff = '';
$enc = '';
if (file_exists($unifilename.'.mtx.php')) {
include($unifilename.'.mtx.php');
}
if (!isset($type) || $type != "TrueTypesubset") {
include_once($this->_getfontpath().'/Applications/MAMP/htdocs/squid/lib/font/');
$ttf = new TTFontFile();
This is the font folder:
squid\lib\tfpdf\font
full path: /Applications/MAMP/htdocs/squid/lib/font/
This is the unifont folder
squid\lib\tfpdf\font\unifont
Full path: /Applications/MAMP/htdocs/squid/lib/font/unifont
When i change the paths i get this error:
[08-May-2018 14:38:02 America/New_York] PHP Warning: include_once(/Applications/MAMP/htdocs/squid/lib/font/): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/squid/lib/tfpdf.php on line 507
[08-May-2018 14:38:02 America/New_York] PHP Warning: include_once(): Failed opening '/Applications/MAMP/htdocs/squid/lib/font/' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.4.45/lib/php') in /Applications/MAMP/htdocs/squid/lib/tfpdf.php on line 507
[08-May-2018 14:38:02 America/New_York] PHP Fatal error: Class 'TTFontFile' not found in /Applications/MAMP/htdocs/squid/lib/tfpdf.php on line 508
include_once($this->_getfontpath().'/Applications/MAMP/htdocs/squid/lib/font/');
This gives an error because you're trying to include an entire folder, you need to specify a filename
$ttf = new TTFontFile();
This gives an error because the class TTFontFile is not defined, maybe its in another file that you didn't include.
Seems like the path returned by
$this->_getfontpath()
is incorrect, or the file you are looking to include is not installed at that path.
You should figure out what $this->_getfontpath() returns, where it is defined. Then see if that path exists and what files are there. Also reading the docs for the library you are installing should help you troubleshooting.
Try changing
/Applications/MAMP/htdocs/squid/lib/font/
to
/squid/lib/font/
does that help?
Hello all this is a simple question which is already there in stack overflow but I tried all the possible answers still it's not fixed
I need to include config file which is under assets folder i tried the following code
include_once '../config.php' ;
am getting error like this
Warning: include(assets/config.php): failed to open stream: No such file or directory in E:\xampp\htdocs\project\assets\handler\ContactHandler.php on line 4
Warning: include(): Failed opening 'assets/config.php' for inclusion (include_path='E:\xampp\php\PEAR') in E:\xampp\htdocs\project\assets\handler\ContactHandler.php on line 4
kindly suggest me a possible way to include config file in ContactHandler.php
ContachHandler.php
<?php
include_once 'E:\xampp\htdocs\project\assets\config.php';
echo "ddddd";
exit;
include (CONTROLLER.'ContactController.php');
$form = $_POST['form'];
$cnt_controller = new ContactController();
switch ($form)
{
case 'AddContact':
$cnt_controller->AddContact($_POST);
break;
case 'ContactUs':
$cnt_controller->ContactUs($_POST);
break;
}
?>
Check to see if your include path changed and check file/folder permissions.
Try out this code:
<?php
$config_path = '../config.php' ;
if (file_exists($config_path)){
require_once $config_path;
}
else {
$config_path = 'config.php';
if (file_exists($config_path)) {
require_once $config_path;
}
else {
$config_path = '../../config.php';
require_once $config_path;
}
}
echo "ddddd";
echo $config_path;
exit;
?>
For testing set static path:
include_once 'E:\xampp\htdocs\project\assets\config.php';
Hope this helps!
I have this error:
Warning: require_once(../questionTypes/Question.php): failed to open stream: No such file or directory in /home/u949913003/public_html/includes/essential.php on line 25
Fatal error: require_once(): Failed opening required '../questionTypes/Question.php' (include_path='.:/opt/php-5.6/pear') in /home/u949913003/public_html/includes/essential.php on line 25
I require essential.php from New_test.php like this:
require_once('../essential.php');
Then in essential.php, I require Question.php like this:
require_once($config['systemQuestionTypesClassDir'].'Question.php');
$config is defined in config.php:
$config['controller']['a'] = 'Admin';
$config['controller']['e'] = 'Teacher';
$config['controller']['t'] = 'Teacher';
$config['controller']['s'] = 'Student';
$config['controller']['at'] = 'Teacher';
$config['controller']['er'] = 'Teacher';
// System directories
$config['systemControllersDir'] = '../controllers/';
$config['systemQuestionTypesClassDir'] = '../questionTypes/';
$config['systemViewsDir'] = '../views/';
$config['systemLibsDir'] = 'libs/';
$config['systemLangsDir'] = 'langs/';
$config['systemQuestionTypesLibDir'] = $config['systemLibsDir'].question;
$config['systemLangsXml'] = '../resources/languages/';
$config['systemExtraDir'] = = 'extra/';
$config['systemFpdfDir'] = 'fpdf/';
$config['systemPhpGraphLibDir'] = 'phpgraphlib—master/';
$config['systemFileManagerDir'] = 'filemanager/';
My folders structure is this:
Obviously in questionTypes there is Question.php.
I don't know ho to solve this.
Calling "include" from another "include" could cause problems when they are relative paths. If you use the absolute path, it shouldn't be a problem.
You could use __DIR__ to get the directory that contains the file where this is written.
I think this should works:
File: New_test.php
require_once(__DIR__ .'/../essential.php');
File: essential.php
require_once(__DIR__ .'/../questionTypes/Question.php');
This question already has answers here:
PHP - Failed to open stream : No such file or directory
(10 answers)
Closed 5 years ago.
I am just trying to make a simple PHP program that allows me to generate my page quickly.
I am completely new at PHP.. And I have no clue what I am doing.
/index.php
<?php
include "/base/startup.php";
echo "Test";
startPage("Home");
?>
I'm getting a 500 server error with this.. Please tell me what I'm doing wrong. Thank you.
/base/startup.php
$HOME = "/";
$SCRIPT = <<<EOD
EOD;
$IMPORTS = array(
"/scripts/script.js"
);
$STYLES = array(
"/styles/style.css"
);
function prnt($string) {
echo $string;
}
function map($func, $arr) {
foreach($arr as $i) {
call_user_func($func, $i);
}
}
function linkScript($script) {
prnt("<script src='$script'></script>");
}
function linkStyle($style) {
prnt("<link rel='stylesheet' href='$style'/>");
}
function startPage($title, $script="", $imports=array(), $styles=array()) {
$pre_tags = array(
"<html>",
"<head>"
);
$post_tags = array(
"</head>",
"<body>"
);
map(prnt, $pre_tags);
prnt("<title>$title</title>");
map(linkScript, $IMPORTS);
map(linkScript, $imports);
map(linkStyle, $STYLES);
map(linkStyle, $styles);
map(prnt, $post_tags);
}
function genNav() {
$nav_links = array(
"Home"=>$HOME,
"Walkthroughs"=>$HOME . "/walkthroughs/",
"Dex"=>$HOME . "dex.php"
);
prnt("<div class='nav'>");
foreach ($nav_links as $key => $value) {
prnt("<a class='link' href='" . $value . "'/>" . $key . "</a>");
}
}
function endPage() {
$endTags = array(
"</body>",
"</html>"
);
}
?>
This is the error:
Warning: include(/base/startup.php): failed to open stream: No such file or directory in /var/www/html/index.php on line 2
Warning: include(): Failed opening '/base/startup.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/index.php on line 2
Test
Fatal error: Uncaught Error: Call to undefined function startPage() in /var/www/html/index.php:4 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 4
Since you mentioned you are on a Linux machine, it looks like the issue is caused because of the / here. The / is considered the root directory of linux machine. So removing the / must most probably work:
<?php
include "base/startup.php"; // Try removing the slash.
echo "Test";
startPage("Home");
?>
Since you haven't enabled the display of errors, the issue would be, there's no /base in your system and it would have thrown an error, like Fatal: Include file not found., which is not displayed because of your configuration, instead it would have shown Error 500 silently.
Update
Along with the above error, after seeing your code, the next one is you need to quote the function names. So replace the stuff with:
map("prnt", $pre_tags);
prnt("<title>$title</title>");
map("linkScript", $IMPORTS);
map("linkScript", $imports);
map("linkStyle", $STYLES);
map("linkStyle", $styles);
map("prnt", $post_tags);
The next error is, you haven't included the global variables correctly inside the function. You need to use:
global $IMPORTS, $STYLES;
Now your code works as expected.
And finally finishing the endPage() function:
function endPage() {
$endTags = array(
"</body>",
"</html>"
);
foreach($endTags as $tag)
echo $tag;
}
I'm in the beginning stages of writing a plugin to display YouTube videos in a WordPress implementation. Here is my code:
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_Youtube');
$yt = new Zend_Gdata_YouTube();
function getAndPrintVideoFeed($location::'http://gdata.youtube.com/feeds/api/users/thelanzolini/uploads/-/step') {
$yt = new Zend_Gdata_YouTube();
// set the version to 2 to receive a version 2 feed of entries
$yt->setMajorProtocolVersion(2);
$videoFeed = $yt->getVideoFeed($location);
printVideoFeed($videoFeed);
}
function printVideoFeed($videoFeed) {
$count = 1;
foreach ($videoFeed as $videoEntry) {
echo "Entry # " . $count . "\n";
printVideoEntry($videoEntry);
echo "\n";
$count++;
}
}
All I get is this error:
I am using MAMP. php is version 5.4.10.
Switching the $location:: above for a $location = I get no errors within the actual plugin file itself but rather in loading various components of Zend.
Errors:
Warning: include_once(Zend/Gdata/Youtube.php): failed to open stream:
No such file or directory in
/Users/mrcsmcln/Documents/MAMP/wordpress/wp-content/plugins/youtube-filter/Zend/Loader.php
on line 134
Warning: include_once(): Failed opening 'Zend/Gdata/Youtube.php' for
inclusion
(include_path='.:/Applications/MAMP/bin/php/php5.4.10/lib/php') in
/Users/mrcsmcln/Documents/MAMP/wordpress/wp-content/plugins/youtube-filter/Zend/Loader.php
on line 134
Warning: require_once(Zend/Exception.php): failed to open stream: No
such file or directory in
/Users/mrcsmcln/Documents/MAMP/wordpress/wp-content/plugins/youtube-filter/Zend/Loader.php
on line 86
Fatal error: require_once(): Failed opening required
'Zend/Exception.php'
(include_path='.:/Applications/MAMP/bin/php/php5.4.10/lib/php') in
/Users/mrcsmcln/Documents/MAMP/wordpress/wp-content/plugins/youtube-filter/Zend/Loader.php
on line 86
What is wrong with my code? Is there a better way I can go about all this?
function getAndPrintVideoFeed($location::'http://gdata.youtube.com/feeds/api/users/thelanzolini/uploads/-/step') {
$yt = new Zend_Gdata_YouTube();
// set the version to 2 to receive a version 2 feed of entries
$yt->setMajorProtocolVersion(2);
$videoFeed = $yt->getVideoFeed($location);
printVideoFeed($videoFeed);
}
Should? possibly? be this: Not familiar with ZF buth this is the regular syntax atleast.
function getAndPrintVideoFeed($location = 'http://gdata.youtube.com/feeds/api/users/thelanzolini/uploads/-/step') {
$yt = new Zend_Gdata_YouTube();
// set the version to 2 to receive a version 2 feed of entries
$yt->setMajorProtocolVersion(2);
$videoFeed = $yt->getVideoFeed($location);
printVideoFeed($videoFeed);
}