armlocker Posted December 28, 2012 Share Posted December 28, 2012 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 More sharing options...
Jonathon Posted December 28, 2012 Share Posted December 28, 2012 It's not a connection error. It's that the file reference isn't correct. So the location you put as the require file doesn't exist - that's all. It might actually just be this require ('includes/mysql.inc.php'); 1 Link to comment Share on other sites More sharing options...
armlocker Posted December 28, 2012 Author Share Posted December 28, 2012 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 More sharing options...
Marie Posted December 29, 2012 Share Posted December 29, 2012 Keep at it and you will learn A LOT. Larry has other books on PHP and MySql, etc. that you should look at as well. It helps to have other sources. Marie 1 Link to comment Share on other sites More sharing options...
Jonathon Posted December 29, 2012 Share Posted December 29, 2012 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 More sharing options...
armlocker Posted December 29, 2012 Author Share Posted December 29, 2012 Thank you everyone! I am learning a lot already. It wont be the last question I post on this forum though. Link to comment Share on other sites More sharing options...
rkovacic Posted September 18, 2013 Share Posted September 18, 2013 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 More sharing options...
rkovacic Posted September 20, 2013 Share Posted September 20, 2013 Turns out the mysql.inc file is not in the 'includes' folder........problem solved. Link to comment Share on other sites More sharing options...
Larry Posted September 20, 2013 Share Posted September 20, 2013 That would do it. Thanks for posting the solution and kudos for getting it working. Link to comment Share on other sites More sharing options...
Recommended Posts