concurrency issues

Discussion in 'PHP' started by naitsir, Sep 25, 2009.

  1. #1
    hi all, i hope some of you can enlighten me. (sorry for my english)

    this is the scenario, i have a infinite loop that is interrupted when set_time_limit reaches the limit, inside the loop performs a query to the DB.
    when i run the php script in firefox, i can't access to the DB from another page of firefox (phpmyadmin, another script, etc) but i can access to the DB from Internet Explorer. I need to open the DB from the same browser without the DB crash.
    i researched and came to the conclusion that there is not a problem of mysql DB.

    Have any of you have idea how fix this?
    I put a piece of code to give you an idea of how it works
    <?php
    set_time_limit(60);
    while( true ){
    ..$sSql = "select state, value1, value... from table"
    ..$res = mysql_query($sSql,$conn);
    ..while ($row = mysql_fetch_assoc($res)){
    ....//do something with the result
    ..}
    }
    ?>
     
    naitsir, Sep 25, 2009 IP
  2. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #2
    why don't you just use the php date function to count 60 seconds?

    I don't really understand what your trying to get from this script at the moment.
     
    Silver89, Sep 25, 2009 IP
  3. naitsir

    naitsir Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    this is an implementation of comet, the idea is show alerts to the user at the time to register in the DB. i set the variable set_time_limit(60); with another value.
     
    naitsir, Sep 26, 2009 IP
  4. TheOnly92

    TheOnly92 Peon

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Use set_time_limit(0) for infinite script execution, if you want to see all the rows.
     
    TheOnly92, Sep 26, 2009 IP
  5. ThomasTwen

    ThomasTwen Peon

    Messages:
    113
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You want to show something to the user x seconds after he comes to your site? JavaScript is the way to go, not PHP.
     
    ThomasTwen, Sep 26, 2009 IP
  6. naitsir

    naitsir Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks for your help.

    the problem is not the runtime, the script will run around an hour.


    thanks Thomas, but this is not the solution :(
    the idea is to inform the user at the exact moment that the DB is update from other side. This show real-time alerts.


    The problem is to access to the DB from the same browser :S
    When i run the script from Firefox, i can't access to the DB fron any other Firefox browser, but i can access from Internet explorer (IE)
     
    naitsir, Sep 28, 2009 IP