Jump to content
Larry Ullman's Book Forums

Config File Connection


Recommended Posts

Hi all,

 

I am reading through chapter 3 and tested it on the server. I've got this error message below.

 

-------------------------------------------------------------------------------------------------------------------

An error occurred in script '/home/ryandivi/public_html/index.php' on line 15:

 

require(/www/includes/mysqli.inc.php) [function.require]: failed to open stream: No such file or directory

 

Array

 

(

 

[0] => Array

 

(

 

[file] => /home/ryandivi/public_html/index.php

 

[line] => 15

 

[function] => my_error_handler

 

[args] => Array

 

(

 

[0] => 2

 

[1] => require(/www/includes/mysqli.inc.php) [function.require]: failed to open stream: No such file or directory

 

[2] => /home/ryandivi/public_html/index.php

 

[3] => 15

 

[4] => Array

 

.

.

.

.

.

---------------------------------------------------------------------------------------------------------------------

 

As it said that it failed to open the config file, I looked at define in my config. I think there must be something wrong with connection path. I wrote my define like this below.

 

//define the constants;

define('BASE_URI','/www/');

define('BASE_URL','www.ryan.divinehosting.ca/');

define('MYSQL', BASE_URI . 'includes/mysqli.inc.php');

 

I am wondering if there's any problem with define('BASE_URI','/www/');. I don't know what to put for this path. My server's web root folder name is 'www'. So I put /www/ for the path..

 

For more information about this issue, I am putting my index.php file as well.

 

Please see below.

 

-------------------------------------------------------------------------------------------------------

 

<?php

 

//include the config file

//it should be the first (noncomment) code in your pages.

include('./includes/config.inc.php');

 

$_SESSION['user_id'] = 1;

$_SESSION['user_type'] = 'admin';

 

//require the header file

include('./includes/header.html');

 

//require database connection

//it connects through define in config file

require(MYSQL);

 

?>

<h3>Welcome</h3>

<p>Welcome to Knowledge is Power, a site dedicated to keeping you up

to date on the web security and programming information you need to

know.Blah Blah Blah. Yadda, yadda, yadda.</p>

 

<?php

include('./includes/footer.html');

?>

 

-------------------------------------------------------------------------------

Thanks in advance and look forward to hearing from you soon.

Link to comment
Share on other sites

I don't know where your MySQL connect file is, but it looks like your base URI should be the following:

 

/home/ryandivi/

 

From there, depending on where the MySQL connect file is, you'll have to adjust the MYSQL constant.

 

Does that make sense?

 

And don't worry, as there have been more questions about the base URI and base URL (especially between XAMPP and a real server) than anything else on this forum.

Link to comment
Share on other sites

 Share

×
×
  • Create New...