Php: mysql_close does interesting things



  • Have a look at the documentation for the php function mysql_close()

    bool mysql_close ( [resource $link_identifier] )


    mysql_close() closes the non-persistent connection to
    the MySQL server  .........

    Parameters

     


    link_identifier

    The MySQL connection. If the
    link identifier is not specified, the last link opened by
    mysql_connect() is assumed. If no such link is found, it
    will try to create one as if mysql_connect() was called
    with no arguments. If by chance no connection is found or established, an
    E_WARNING level warning is generated.

     ----------------

    So if you call mysql_close and there is no open connection, it will try to open a new connection, just to close it again.

    Very clewer :} 



  • Hey, at least it does what you tell it!



  • @tiller said:

    Have a look at the documentation for the php function mysql_close()

    bool mysql_close ( [resource $link_identifier] )


    mysql_close() closes the non-persistent connection to
    the MySQL server  .........

    Parameters

     


    link_identifier

    The MySQL connection. If the
    link identifier is not specified, the last link opened by
    mysql_connect() is assumed. If no such link is found, it
    will try to create one as if mysql_connect() was called
    with no arguments. If by chance no connection is found or established, an
    E_WARNING level warning is generated.

     ----------------

    So if you call mysql_close and there is no open connection, it will try to open a new connection, just to close it again.

    Very clewer :} 

    Reminds me of the old joke "how does a mathematican make a cup of coffee". 



  • @ammoQ said:

    Reminds me of the old joke "how does a mathematican make a cup of coffee". 


    I haven't heard that one please share.



  • @Lingerance said:

    @ammoQ said:

    Reminds me of the old joke "how does a mathematican make a cup of coffee". 


    I haven't heard that one please share.

     

    Apparently also hard to find via google, best one i found that involves math and coffee is the following


    "Divide fourteen sugar cubes into three cups of coffee so that each cup has an odd number of sugar cubes in it."

    "That's easy: one, one, and twelve."

    "But twelve isn't odd!"

    "It's an odd number of cubes to put in a cup of coffee..."

     



  • @Lingerance said:

    @ammoQ said:

    Reminds me of the old joke "how does a mathematican make a cup of coffee". 


    I haven't heard that one please share.

    How does a mathematican make a cup of coffee? 

    He goes into the kitchen opens the kitchen cabinet, takes out the mug and a jar of Nescafe (operating a coffee grinder is way too much work), opens the jar, opens the drawer, takes out a coffee spoon, puts a spoon of Nescafe into the mug, starts the electric kettle, waits till the water is hot, pours hot water into the mug, stirs the coffee, finished.

    The next day, the mathematican again wants a cup of coffee. But he has a problem: This time, the initial situation is different. So he closes the jar of Nescafe, puts it back into the kitchen cabinet and closes the kitchen cabinet. This way, the problem is reduced to a well known problem, so he can apply the solution found the day before.



  • ROFL!!!

    The real WTF is that ammoQ has, like over 2,000 posts!  The dude rocks!



  • To be fair, PHP admitted their mistake about this entirely retarded behavior of using an "implicit" connection when none exist and did away with it in the mysqli extension. And if you're still using the mysql extension, you should be shot.



  • @ammoQ said:

    "how does a mathematican make a cup of coffee".

    He could find one of his co-workers -- this'd be a co-mathematician. But, in maths parlance, co- means inverse, so he could feed theorems to this inverse mathematician 'til he produces that cup of coffee. Simple!



  • @Irrelevant said:

    @ammoQ said:
    "how does a mathematican make a cup of coffee".

    He could find one of his co-workers -- this'd be a co-mathematician. But, in maths parlance, co- means inverse, so he could feed theorems to this inverse mathematician 'til he produces that cup of coffee. Simple!

    In the real world, the mathematician would just prove the existence of a cup of coffee and declare actually producing it trivial. 



  • @ammoQ said:

    In the real world, the mathematician would just prove the existence of a cup of coffee and declare actually producing it trivial. 

    Naw. He'd just declare the existence of coffee and leave actual production of said cup as an exercise to the (reader|grad student).


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.