Hey everyone I'm trying to create a blog using php and for a certain page, I am "including" an "init.php" file that doesn't seem to recognize...I have three folders within another folder called "test5" and within that folder I have the folders called: "func" "resources" and "simple".

Now in the folder labeled "resources" are files called ".htacces", "config.php", and "init.php".

The only script in the folder labeled "func" is "blog.php"..

In the folder labeled "simple", I have the files labeled, "add_category.php", "edit_post.php", "category_list.php", "category.php", "add_post.php" and "add_category".

The issue is when I open the "add_category.php" the error shows as follows:
"Warning: include_once(resources/init.php) [function.include-once]: failed to open stream: No such file or directory in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\simple\add_category.php on line 2"

and

"Warning: include_once() [function.include]: Failed opening 'resources/init.php' for inclusion (include_path='.;C:\php\pear') in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\simple\add_category.php on line 2"

here is add_category.php

<?php
include_once('resources/init.php');

if ( isset($_POST['name'])) {
	$name = trim($_POST['name']);
	
	if ( empty($name)) {
		$error = "You must submit a category name!";
	} else if (category_exists($name)){
		$error = "That category already exists!";
	} else if (strlen($name) > 24) {
		$error = "Category names can only be up to 24 characters!";
	}
	
	if ( ! isset($eror)){
		add_category($name);
	}
}
?>
<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    
    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    
    <title> Add a Category </title>
</head>

<body>
    <h1> Add a Category </h1>
    
    <form action="" method="post">
        <div>
            <label for="name"> Name </label>
            <input type="text" name="name" value="">
        </div>
        <div>
            <input type="submit" value="Add Category">
        </div>
    </form>
</body>
</html>

and here is init.php

<?php

include_once('resources/config.php');

mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_connect(DB_NAME);

include_once('func/blog.php');

if there is any confusion, I'll try to answer as best as I can because to me this is a complicated process, but ANY help would greatly be appreciated!! :D

Member Avatar for diafol

gave me a nosebleed ...
anyway how about:

include_once('../resources/init.php');

etc.

@ardav:..sorry about that.. ..when I added that, a whole crapload of errors showed...

"Notice: Use of undefined constant DB_HOST - assumed 'DB_HOST' in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\resources\init.php on line 5

Notice: Use of undefined constant DB_USER - assumed 'DB_USER' in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\resources\init.php on line 5

Notice: Use of undefined constant DB_PASS - assumed 'DB_PASS' in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\resources\init.php on line 5

Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\resources\init.php on line 5

Warning: mysql_connect() [function.mysql-connect]: [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. (trying to connect via tcp://DB_HOST:3306) in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\resources\init.php on line 5

Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\resources\init.php on line 5

Notice: Use of undefined constant DB_NAME - assumed 'DB_NAME' in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\resources\init.php on line 6

Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\resources\init.php on line 6

Warning: mysql_connect() [function.mysql-connect]: [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. (trying to connect via tcp://DB_NAME:3306) in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\resources\init.php on line 6

Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\resources\init.php on line 6

Warning: include_once(func/blog.php) [function.include-once]: failed to open stream: No such file or directory in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\resources\init.php on line 8

Warning: include_once() [function.include]: Failed opening 'func/blog.php' for inclusion (include_path='.;C:\php\pear') in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\resources\init.php on line 8"

ok..sorry, I added that same concept "../" to all the other "includes" now it just shows:
"Parse error: syntax error, unexpected '}' in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\resources\config.php on line 10"

I know this seems pretty basic but nothing seems to be wrong..that "}" should go right where it is..there should be no error..

ok..I re-did my config.php file so it reads as follows:

config.php

<?php

$dbhost = '************';
$dbusername = '*****';
$dbpasswd = '';
$database_name = 'blog';

$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd") 
	or die ("Couldn't connect to server.");
	
$db = mysql_select_db("$database_name", $connection)
	or die("Couldn't select database.");
?>

and for the blog.php it shows this error "Parse error: syntax error, unexpected ';' in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\test5\func\blog.php on line 33"

blog.php

<?php
function add_post($title, $contents, $category) {
	
}

function edit_post($id, $title, $contents, $category){
	
}

function add_category($name){
	$name = mysql_real_escape_string($name);
	
	mysql_query("INSERT INTO 'categories' SET 'name' = '$name'");
}

function delete($field, $id){
	
}

function get_posts($id = null, $cat_id = null){
	
}

function get_categories($id = null){
	
}

function category_exists($name){
	$name = mysql_real_escape_string($name);
	
	$query = mysql_query("SELECT COUNT(1) FROM 'categories' WHERE 'name' = '$name'");
	
	return ( mysql_results($query, 0) == '0' ) ? false; true;
}

I don't see anything wrong.. :/

sorry I should start a new thread, the include part was answered thanks to ardav :)

I have these errors in the administrator page what should I do???

Warning: include_once(C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\administrator/templates../new04/html/modules.php) [function.include-once]: failed to open stream: No such file or directory in C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\libraries\joomla\application\module\helper.php on line 186

Warning: include_once() [function.include]: Failed opening 'C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\administrator/templates../new04/html/modules.php' for inclusion (include_path='.;C:\php\pear') in C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\libraries\joomla\application\module\helper.php on line 186

Warning: include_once(C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\administrator/templates../new04/html/modules.php) [function.include-once]: failed to open stream: No such file or directory in C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\libraries\joomla\application\module\helper.php on line 186

Warning: include_once() [function.include]: Failed opening 'C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\administrator/templates../new04/html/modules.php' for inclusion (include_path='.;C:\php\pear') in C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\libraries\joomla\application\module\helper.php on line 186

Warning: include_once(C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\administrator/templates../new04/html/modules.php) [function.include-once]: failed to open stream: No such file or directory in C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\libraries\joomla\application\module\helper.php on line 186

Warning: include_once() [function.include]: Failed opening 'C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\administrator/templates../new04/html/modules.php' for inclusion (include_path='.;C:\php\pear') in C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\libraries\joomla\application\module\helper.php on line 186

Warning: include_once(C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\administrator/templates../new04/html/modules.php) [function.include-once]: failed to open stream: No such file or directory in C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\libraries\joomla\application\module\helper.php on line 186

Warning: include_once() [function.include]: Failed opening 'C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\administrator/templates../new04/html/modules.php' for inclusion (include_path='.;C:\php\pear') in C:\Program Files (x86)\EasyPHP-5.3.9\www\Joomla\libraries\joomla\application\module\helper.php on line 186

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.