Jump to content

RealDrift

Members
  • Posts

    158
  • Joined

  • Last visited

    Never

Posts posted by RealDrift

  1. - i meant that that frame in which the two images are mustn't display the inbox page. but it somehow does. that frame is only for the two images.

     

    - you suggest the ajax script doesn't work, then why does it work when i just echo a word etc?

  2. ok the SQL error is gone, the right username is printed.

     

    - but firstly is still displays the wrong pic, but shows correct one upon manual refresh.

    - secondly it randomly displayed my inbox in that frame.

     

    also i tried just echoing a word instead of any statement and then i saved the file. my webpage displayed the right word. then i changed the word in the echo statement to something else and saved it. The webpage again showed correct word.

     

    i get the feeling the AJAX script does auto refresh. just thought this might help you

  3. Hi,

     

    i have seen a website use this feature. basically the mouse pointer changes to a different one if the user has  a new message in their inbox. Once the message is read the mouse pointer goes back to the original one.

     

    i run a website which has a members section in which they can message each other. This feature is kinda good to have.

     

    any help appreciated.

     

    thanks

  4. Mr_mind i did what you said and got the following results:

     

    - i echoed the two things and got:

     

    WentWorthYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read='0' AND to='WentWorth'' at line 1

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\game\box.php on line 75

     

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\game\box.php on line 76

     

    this shows that the $username variable picks up the correct username but i dn't know why the SQL statement is suggested to be incorrect.

     

    - the image is shown but the correct image is not displayed, and even when i manually refresh the frame the correct image is not shown

     

    so thats the problem now :(

  5. mr minds code is correct echo the select statement out ok....

     

     

     

     

    having probs with this line, gives me an error:

     

    $inbox_query = mysql_query("SELECT * FROM inbox WHERE read='0' AND to='" . $inbox_user . "'");

  6. its not online, but on my pc

     

    btw i think the page is refreshing, but each time it refreshes it just displays a duplicate image below, and more images appear wtf?

     

    i added exit(); at the end and no more duplicate images

  7. i want the frame to display one pic if the user has new messages and another different pic if it dsnt. Before i used html to auto refresh page every 10 secs.

     

    that was annoying for the user. as the user could notice the refresh and the images used to flicker.

     

    i found out that AJAX could perfrom the refresh for me better hence i tried usign that.

     

    but the frame dsnt refresh automatically, but it does display correct info when i refresh manually.

  8. the AJAX and php are in the same file. i will post the code below. one frame on my page is the file i will post below:

     

    <?php 
    session_start(); 
    include "includes/db_connect.php"; 
    include"includes/functions.php"; 
    logincheck();
    $username=$_SESSION['username'];
    $query=mysql_query("SELECT * FROM users WHERE username='$username'");
    $fetch=mysql_fetch_object($query);
    $inbox_msg=mysql_num_rows(mysql_query("SELECT * FROM `inbox` WHERE `read`='0' AND `to`='$username'"));
    $check = mysql_query("SELECT `to`,`read` FROM `inbox` WHERE `read`='0' AND `to`='$username'");
    
    
    ?>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    
    
    <script language="javascript">
    function createRequestObject() {
    
       var req;
    
       if(window.XMLHttpRequest){
          // Firefox, Safari, Opera...
          req = new XMLHttpRequest();
       } else if(window.ActiveXObject) {
          // Internet Explorer 5+
          req = new ActiveXObject("Microsoft.XMLHTTP");
       } else {
          // There is an error creating the object,
          // just as an old browser is being used.
         alert("Your Browser Does Not Support This Script - Please Upgrade Your Browser ASAP");
       }
    
       return req;
    
    }
    
    // Make the XMLHttpRequest object
    var http = createRequestObject();
    
    function sendRequest(page) {
    
       // Open PHP script for requests
       http.open('get', page);
       http.onreadystatechange = handleResponse;
       http.send(null);
    
    }
    
    function handleResponse() {
    
       if(http.readyState == 4 && http.status == 200){
    
          // Text returned FROM the PHP script
          var response = http.responseText;
    
          if(response) {
             // UPDATE ajaxTest content
             document.getElementById("msgstatus").innerHTML = response;
          }
    
       }
    
    }
    
    function repeatloop()
    {
    sendRequest('box.php'); // replace "inbox-status.php" with your php page's url
    setTimeout("repeatloop()", 3000);
    }
    
    window.onload=function() {
    repeatloop();
    }
    </script>
    
    <title>The Legendary Mafia</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    body {
    background-image: url(images/banner/gradient.gif);
    background-repeat: repeat-x;
    }
    -->
    </style></head>
    
    <body>
    
    <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="100%" height="70" background="" scope="col">
      <div align="center"><p>
            <?php
    
    $inbox=mysql_num_rows($check);
    if ($inbox > 0){ 
    echo "<a href=inbox.php target=middle><img border=0 src=images/unread1.gif align=center  width=16 height=11></a> "; 
    }else{ 
    echo "<img src=images/read.gif align=center width=16 height=11>";
    } 
    
    ?>
          <span id="msgstatus"></span></p>
          </div></td>
      </tr>
    </table>
    </body>
    </html>

  9. you know what? i start over again:

     

    i want to have an image on my website which changes to another pic when a user gets a new message and change back to the original pic once the user has read the message.

     

    how can i refresh the info without page refresh, any unique ways to some how have a live connection with the server or something?

  10. Sorry teng for replying late i had an exam to revise for. now thats over with.

     

    I tried your script and the results are as follows:

     

    - it echos the new message i recieve

    - i have to manually refresh the page for the right image to appear and onc ei read the new message i have to refresh the page again and the picture changes to the appropriate one.

    -only problem is ajax dsnt seem to change the pics.

     

     

    hmm?

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.