How to close a leaking Php code?

Discussion in 'PHP' started by TheSyndicate, Jan 22, 2006.

  1. #1
    My sweden server guy says my code leaks or he thinks thats my server overload and shuts down. He says i have not closed my code? Ok i understand closing the code but is there any software i can use to check this quick before my server sinks once more.
     
    TheSyndicate, Jan 22, 2006 IP
  2. Important

    Important Peon

    Messages:
    87
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think he is pointing towards mysql connections or something similar.. Just ask him for more details.
     
    Important, Jan 22, 2006 IP
    TheSyndicate likes this.
  3. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #3
    He just think that is the problem and i have no clue
     
    TheSyndicate, Jan 22, 2006 IP
  4. Important

    Important Peon

    Messages:
    87
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Maybe you can put up your code source somewhere so that people can help you analyze?
     
    Important, Jan 22, 2006 IP
  5. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Every connection you make to a database needs to be closed once you have finished using it.

    You use mysql_close(); to do this. Servers have a maximum number of connections and if you don't close them you need to wait until they expire leading to a "Too many connections" error.
     
    dave487, Jan 22, 2006 IP
    TheSyndicate likes this.
  6. Important

    Important Peon

    Messages:
    87
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yes, dave is right. Use of mysql_close is compulsory esp. when using persistent connections. Otherwise, PHP is capable of closing open links automatically as soon as execution of a php script completes.
     
    Important, Jan 22, 2006 IP
  7. sarahk

    sarahk iTamer Staff

    Messages:
    28,828
    Likes Received:
    4,541
    Best Answers:
    123
    Trophy Points:
    665
    #7
    The mysql thing is quite easy to close, just check in your footer script.

    It's possible though that you have something that is looping indefinately

    Or a hyperlink that's poorly formed and sending search engine bots in an endless chase for dynamically generated pages. I checked a site the other day and it had some results that looked like this

    mysite.com/dirname/info.php
    mysite.com/dirname/dirname/info.php
    mysite.com/dirname/dirname/dirname/info.php
    mysite.com/dirname/dirname/dirname/dirname/info.php
    mysite.com/dirname/dirname/dirname/dirname/dirname/info.php
    mysite.com/dirname/dirname/dirname/dirname/dirname/dirname/info.php

    You get the picture - none of it was intended, just a nasty wee typo will do that. I use Xenu to scan sites and it's intended for broken links but picks this up too :0
     
    sarahk, Jan 23, 2006 IP
    TheSyndicate likes this.
  8. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #8
    Hi Dave 487 well we made almost 40 diffrent websites with code ourself and we also have 160 with people other codings so putting up the code here will be a problem. The problem the server people i just think tossing out comments to blaim anything else then themself.

    Sarah i downloaded the program and will use it to check the domains one by one would not take long. Thanks :)
     
    TheSyndicate, Jan 23, 2006 IP