Jump to content
Larry Ullman's Book Forums

Mysql.Inc.Php Failing To Connect


Recommended Posts

Hiya - I'm having difficulty connecting to the database with the mysql.inc.php. Here's the error message:

 

<-- error message ==========

 

An error occurred in script '/hermes/waloraweb004/b1384/moo.laissezfairelondonco/wolfcut/index.php' on line 9:

require(/home/users/web/b1384/moo.laissezfairelondonco/wolfcut/wolfcut/includes/mysql.inc.php) [function.require]: failed to open stream: No such file or directory

 

========= -->

 

Really basic, I know, but I'm trying to follow an examples between pages 49-71 in the ecommerce book and the above error keep happening. As far as I can gather, the 'user, password, host, db name' are all correct.

 

I am directly uploading files to server and full error code can be seen at: http://www.wolfcut.co.uk/

 

Assistance much appreciated

Link to comment
Share on other sites

OMG ==== you are an absolute genius :) Totally worked:

 

Before I had this in the index.php:

require ('MYSQL');

 

And upon your advice, it is now this:

require ('./includes/mysql.inc.php');

 

I'm not sure if you have the Larry's book, but I must have mis-understood what he meant on page 70 ".....The database connection script can be included by referring to the MYSQL constant, defined in the configuration file. This means that even if you change the name or location of mysql.inc.php, you have to change only one line in the configuration file and all your pages will still include that script properly." ---- I thought this meant require ('MYSQL'); can locate the mysql.inc.php anywhere (silly me)

 

It's so difficult to learn this solely from book - so really glad you fixed this for me so quick!

Link to comment
Share on other sites

I've got the book yes. But it's been a long time since I read it though.

 

From memory he does something like this:

 


define ('BASE_URI', '/path/to/dir/');
define ('BASE_URL', 'www.example.com/');
define ('MYSQL', BASE_URI . 'mysql.inc.php');

 

If this is your first book for PHP it might be difficult at times. His latest 4th edition PHP and MYSQL is a very good book and will give you a great grounding in most web development areas.

 

Good luck

Link to comment
Share on other sites

  • 8 months later...

I am getting similar errors when trying to connect to MYSQL (constant):

 

An error occured in script '/Applications/MAMP/htdocs/phase 1/html/index.php' on line 20: 
require(includes/mysql.inc.php): failed to open stream: No such file or directory

 

When I alter the file path, I get -

 

An error occured in script '/Applications/MAMP/htdocs/phase 1/html/index.php' on line 20:
require(./includes/mysql.inc.php): failed to open stream: No such file or directory

 

I get the same error messages whether I call the Constant, or use the actual file path.

 

Help???

Link to comment
Share on other sites

 Share

×
×
  • Create New...