Results 1 to 7 of 7

Thread: Help me please...

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Czech Republic
    Posts
    52

    Arrow Help me please...

    Hi, help me please. I need write to mysql and after this window close. But when window is closing then mysql haven't time to write. (because window is closing)

    The closing must waiting while information is writed in mysql database.
    (on local host have writing time and all is OK but on Net Or Internet it's bad)

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Help me please...

    What window are you talking about? A window that you have opened or the main browser window?

  3. #3
    Fanatic Member jcavard's Avatar
    Join Date
    Jul 2005
    Location
    Quebec, CANADA
    Posts
    534

    Re: Help me please...

    yiiish...

    really can't figure out what window you are talking about...
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

    accoustic emo-rock band: a tailormade fable

    Visual Studio 2003 / Framework 1.1

  4. #4
    Lively Member
    Join Date
    Jul 2004
    Posts
    121

    Re: Help me please...

    Dobré ráno.
    How are you trying to close the page?
    I expect you are using a combination of server-side and client-side, so the MySQL should be completed before you get anywhere near the client-side.
    Code:
    <?
    
    // DO YOUR INSERT/UPDATE/DELETE, WHATEVER UP HERE
    
    // NOW CLOSE THE WINDOW
    echo '<script> window.close(); </script>';
    
    ?>
    Perhaps seeing the code will help.

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Czech Republic
    Posts
    52

    Arrow Re: Help me please...

    I need write to MYSQL with event ONUNLOAD.
    I try:
    <body onunload=window.open("win.php")>

    and in this page (win.php) I have code to write to MYSQL.
    But it's problem.
    ..
    ..
    mysql_db_query('..','..','..');
    ..
    ..
    ?>
    <script>window.close()</script>

    mysql haven't more time to write

  6. #6
    Lively Member
    Join Date
    Jul 2004
    Posts
    121

    Re: Help me please...

    I've experienced that before actually. Instead of writing the javascript below your last delimeter (?>), make sure to echo it, like this:
    Code:
    echo '<script> window.close(); </script>';
    If it still doesn't work, I haven't a clue.

  7. #7
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Help me please...

    Opening a new window might anoy the user, i know it would annoy me. You can do what you want without the users seeing it using ajax.

    PHP Code:
    <html>
    <
    head>
    <
    script language="javascript">
    function 
    createRequestObject()
    {
        var 
    request_o//declare the variable to hold the object.
        
    var browser navigator.appName//find the browser name
        
    if(browser == "Microsoft Internet Explorer"){
            
    /* Create the object using MSIE's method */
            
    request_o = new ActiveXObject("Microsoft.XMLHTTP");
        }else{
            
    /* Create the object using other browser's method */
            
    request_o = new XMLHttpRequest();
        }
        return 
    request_o//return the object
    }

    var 
    http createRequestObject();
    function 
    ClosingWindow()
    {
        
    http.open('get''win.php');
        
    http.send(null);
    }
    </
    script>
    </
    head>
    <
    body onunload="javascript:ClosingWindow();">

    <!--
    // Your page information //-->

    </body>
    </
    html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width