force a new connection to mysql?

Discussion in 'PHP' started by n30n30, Jul 21, 2008.

  1. #1
    hi

    i wish to log mysql error syntax errors to the database. to do this i close the connection in the error handler and then open a new one (everything returns success at this point). the problem is that - when i attempt to send a query - the new connection gives the same error that originally caused the error to be thrown.

    this leads me to suspect that closing and then opening a connection isnt actually getting me a new connection.

    ps. mysql_connect is ignoring the new_link flag

    any help gratefully received, thank you
     
    n30n30, Jul 21, 2008 IP
  2. wdillsmith

    wdillsmith Peon

    Messages:
    37
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I have done this successfully before. For example:

    
    $connection = dbConnect();
    $query = "some query";
    if (!($result = @ mysql_query ($query, $connection)))
    {
        $connection2 = dbConnect();
        $result = @ mysql_query ($query, $connection2)
    }
    
    Code (markup):
     
    wdillsmith, Jul 22, 2008 IP