"connect failed"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • delset
    New Member
    • Nov 2006
    • 1

    "connect failed"

    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('D B.php')?? i require_once('D B.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('D B.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!
  • yeahuh
    New Member
    • Nov 2006
    • 4

    #2
    Originally posted by delset
    could there be a problem with the require_once('D B.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_on ce() 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

    Comment

    Working...