Jeff Posted March 26, 2011 Share Posted March 26, 2011 Hi everyone, I am set up with xampp on my home pc, while I am going through the book and everything has worked great up to this point. In chapter 8 Larry talks about connecting to the db. First he has us put a temporary copy of mysqli_connect.php in the htdocs folder and look for a blank page when you run it in your browser. When I do that it works fine, then he says to delete that copy and just keep the mysqli_connect.php outside the htdocs folder for more security. In this case I saved it in the xampp directly that is just above the htdocs folder. When I do that I cannot connect any longer. Is this normal, or am I missing something? Link to comment Share on other sites More sharing options...
Jonathon Posted March 26, 2011 Share Posted March 26, 2011 Hi Jeff You can either use an absoulte path which is the full path to the file or a relative one like "../folder/connect.php" to access files in a folder above where the script is executed. 1 Link to comment Share on other sites More sharing options...
Stuart Posted March 26, 2011 Share Posted March 26, 2011 Have you changed the include path to the script? So would become something like: include('../mysqli_connect.php'); 1 Link to comment Share on other sites More sharing options...
Jeff Posted March 27, 2011 Author Share Posted March 27, 2011 Thanks guys I think in the exercise we create the mysqli_connect.php and test it in the htdocs folder to make sure it works then we put it in the preceding folder for use in the next script. I moved on to the next script (script 8.3 register.php where I do see the include ('../mysqli_connect.php') so I think I am ok there. In working with register.php when I fill out the form correctly and try to submit I get a bunch of errors like: Notice: Constant DB_USER already defined in C:\xampp\mysqli_connect.php on line 7 Notice: Constant DB_PASSWORD already defined in C:\xampp\mysqli_connect.php on line 8 Notice: Constant DB_HOST already defined in C:\xampp\mysqli_connect.php on line 9 Notice: Constant DB_NAME already defined in C:\xampp\mysqli_connect.php on line 10 These errors repeat over and over a ton of times before the final error is posted: Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\mysqli_connect.php on line 7 The errors don't lie as in the previous exercise we did define the db user,password, host, and name. I thought we needed that to access the db. Any ideas. Link to comment Share on other sites More sharing options...
Jeff Posted March 27, 2011 Author Share Posted March 27, 2011 Forget it, I still had the (include('../mysqli_connect.php'); in the mysqli_connect.php and that is why I was getting those errors. I took it out and it worked fine. Thanks again for the help. I am in the service business and in that business we call this take a call, make a call. lol 1 Link to comment Share on other sites More sharing options...
Jonathon Posted March 27, 2011 Share Posted March 27, 2011 Hi Jeff, It looks like your trying to include the constant again. If you post the code that your including the mysqli file it might show us where the problem is. Link to comment Share on other sites More sharing options...
Jonathon Posted March 27, 2011 Share Posted March 27, 2011 Glad you sorted it Jeff. For reference if you get stuck its probably best to post your code so people can have a look if there's something wrong in it. Though probably best you *** out your connection details. 1 Link to comment Share on other sites More sharing options...
Recommended Posts