1 Replies - 392 Views - Last Post: 23 May 2013 - 05:22 PM Rate Topic: -----

#1 seyidesh  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 51
  • Joined: 24-November 10

Include Path Error

Posted 23 May 2013 - 04:19 PM

Hello Guys, Please i need someone to explain to me what i got wrong in the code that is throwing me error

The CODE in init.inc.php file :

<?php
include_once 'connect.php';

$path = dirname(__FILE__);

include('{$path}/classes/user.inc.php');

$_SESSION['user_id'] = 1;


?>



Then I try to include the file like this on another page to test if it is working.

<?php include ('classes/init.inc.php');  ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Member List page</title>
</head>

<body>
	<div>
		<?php
		
		?>
	</div>
</body>
</html>



THE ERROR THROW IS THIS:


Warning: include({$path}/classes/user.inc.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\forum\classes\init.int.php on line 6


This line in question is include('{$path}/classes/user.inc.php');

Can anyone explain to me where my mistakes are?

Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: Include Path Error

#2 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 948
  • View blog
  • Posts: 2,357
  • Joined: 15-February 11

Re: Include Path Error

Posted 23 May 2013 - 05:22 PM

Hey,

The problem lies with your quotes. Variables in single quotes will not be parsed by PHP. Only those that are within double quotes. You won't need the braces since it's not an array by the way.

I would also suggest looking into a template engine. It will make separating your code a lot easier and organized. Have a look at Smarty Template Engine -> tutorial

This post has been edited by codeprada: 23 May 2013 - 05:23 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1