I had a prototype of my website working correctly, meaning it connected to the database correctly. This was done with just one file called "connect.php" which had mysql_connect() and such inside it. I then separated the connect information into to separate files, one containing the account information (account.php) and one containing the connect function (connect.php), with correct information (I triple checked) and it isn't connecting properly. All I can think of is that I'm not including it the right way. This is what I have in a file:
<?php
include('account.php');
include('connect.php');
include('functions.php');
.....
?>
Edit: I would first like to thank everyone for the down-votes, you're all so supportive. Secondly, I seemingly fixed my problem by changing single quotes to double quotes with the include() function and a deleted a few excess spaces. I'm not quite sure how this changed anything, but apparently it had.
Include executes all of the code inside the file right away, and performs exactly as if you were copy-and-pasting the files into the document. This is different from how C or other languages handle #include
statements. Pretend you are copy and pasting your code from those 3 files into one file, in that order... would it work? If not, then the reason that isn't working is the same as the reason this isn't working. (Logical sanity check for include()
)
based on your description of what's happening and the names of the files i would assume a couple of things:
but yeah you should have debugging turned on or put echo statements after each include (ie echo "1";exit;) to see which include is failing or causing errors.
just an initial place to start given the provided information.
i hope this helps :)