By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,022 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

"connect failed"

P: 1
This is my first post on this form so please bear with me if i don't give all the needed info. My problem seems simple but i googled for hours and have not yet found anything that can help with my problem at all.


It is hard for me to explain but basically...

I have a function that uses PEAR DB to connect to mysql and display a table from the database. Then the user submits a change in the table and this sends it to a different php file that then uses PEAR to update the database and then calls the function again to display the next table in the database that is to be reviewed/updated/viewed.

the problem is the first time the function is called it connects to the database just fine and everything works smoothly and i echo "Table Updated" and close the connection to the database. In the same php file that updated the database i then try to call the function again to display the next table to be updated but it comes up with the error "connect failed"

i can't understand why the function connects and works just fine the first time but when i try to call it again it just doesn't work. After each connection to the database i use $connection->disconnect(); to ensure that i don't have multiple connections open because i thought that may be the problem...

i have also had a few problems with require_once.... should it not matter at all how many times you require_once('DB.php')?? i require_once('DB.php') inside each function....

i have been going crazy trying to get this code to work and I just can't make sense out of why the connection fails the second time and not the first!

could there be a problem with the require_once('DB.php') being in the code twice... once at the top of the new file and the second time in the function that i am calling??

help!!! any ideas i would like to hear them... im new to this!
Nov 15 '06 #1
Share this Question
Share on Google+
1 Reply


P: 4
could there be a problem with the require_once('DB.php') being in the code twice... once at the top of the new file and the second time in the function that i am calling??
I'm new as well so belive me i feel your pain lol.

php.net says "require_once() should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc."

I would asume it's not the root of your problem but as i say i am new as well.
I realise this post isnt of a lot of help but it is a bump back to the first page =p
Nov 17 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.