Jump to content

RealDrift

Members
  • Posts

    158
  • Joined

  • Last visited

    Never

Everything posted by RealDrift

  1. i have put the IF statement back into the file which has the AJAX refresh script, between the span tags. now the first uread1.gif is displayed but it dsnt change to read.gif when i read the unread messages.
  2. mr_mind complicated the code for me. here is the original simple code : <?php session_start(); include "includes/db_connect.php"; include "includes/functions.php"; logincheck(); $username=$_SESSION['username']; $viewuser=$_GET['viewuser']; $check = mysql_query("SELECT * FROM `inbox` WHERE `read`='0' AND `to`='$username'"); $inbox=mysql_num_rows($check); if ($inbox > 0){ echo "<a href=inbox.php target=middle><img border=0 src=images/unread1.gif align=left width=16 height=11></a> "; }else{ echo "<img src=images/read.gif align=left width=16 height=11>"; } ?>
  3. i changed that part and then refreshed the page, no pic showed and when AJAX refresh the page second later i got that session error again
  4. now i undid to the original code and gt this error: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\game\refresh.php:9) in C:\xampp\htdocs\game\includes\functions.php on line 2
  5. it shows the pic if there is no IF statements attached to it, like: print '<img border="0" align="left" src="images/unread1.gif" width="16" height="11">'; what could be wrong?
  6. images/unread1.gif images/read.gif what source code? i have given you the main file source code which is the first code and the second code is the script which shows image according to status.
  7. look at the second code i just gave you: Lines: print '<img border=0 align=left src=images/'; if($inbox_num > 0) { print 'unread1'; } else { print 'read'; } print '.gif width=16 height=11></a>';
  8. basically the AJAX script works fine and refresh the text between the span tags. It displays text, however it doesn't seem to show the images in the php script. It should refresh to show one image if user has new messages and refresh to show another image if user has no new messages. But it dsnt display either pic. does that help?
  9. Here is the php script where the message icon is meant to be displayed, it has the AJAx refresh code in it too: <?php session_start(); include "includes/db_connect.php"; include "includes/functions.php"; logincheck(); $username=$_SESSION['username']; $viewuser=$_GET['viewuser']; $check = mysql_query("SELECT * FROM `inbox` WHERE `read`='0' AND `to`='$username'"); $inbox=mysql_num_rows($check); $query=mysql_query("SELECT * FROM users WHERE username='$username'"); $fetch=mysql_fetch_object($query); $currank=$fetch->rank; $fetch2=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'")); ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel=stylesheet href=includes/in.css type=text/css> <style type="text/css"> <!-- .style2 {font-size: 12} .style3 {font-size: 11px} --> </style> <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('refresh.php'); // replace "inbox-status.php" with your php page's url setTimeout("repeatloop()", 3000); } window.onload=function() { repeatloop(); } </script> </head> <body> <table width="110%" height="10" border="0" cellPadding="0" cellSpacing="0" bordercolor="#737373" class="thinline" id="Table1" style="LEFT: 0px; POSITION: absolute; TOP: 0px; height: 100%;" name="Table1"> <tr valign="middle"> <td width="4%" align="left" valign="middle"><div align="center"><span id="msgstatus">the span tags are here for the AJAx refresh script</span></div></td> <td width="96%" bgcolor="#737373"><span class="style3"><strong>Rank: </strong> </b></font></a> </span></td> </tr> </table> </body> </html> this is the php script which determines what pic to display: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php include "includes/db_connect.php"; include "includes/functions.php"; if(logincheck()) { if(isset($_SESSION['username']) && isset($_GET['viewuser'])) { $inbox_user = $_SESSION['username']; $inbox_num_query = mysql_query("SELECT * FROM `inbox` WHERE `read`='0' AND `to`='$username'"); $inbox_num = mysql_num_rows($inbox_num_query); print '<td width=4% align=left valign=middle>'; print '<span id=msgstatus class=style2>'; print '<a href=inbox.php target=middle>'; print '<img border=0 align=left src=images/'; if($inbox_num > 0) { print 'unread1'; } else { print 'read'; } print '.gif width=16 height=11></a>'; print '</span>'; print '</td>'; } } ?> </body> </html> there you have it, anything wrong with the above?
  10. the function was defined in: include "includes/db_connect.php"; include "includes/functions.php"; i included those at the top now the error is gone, but no image, If i just echo image without an IF statement the image is displayed.
  11. i changed it and got error: Fatal error: Call to undefined function logincheck()
  12. Hi, An AJAX script refreshes a file containing the following code: logincheck(); $username=$_SESSION['username']; $viewuser=$_GET['viewuser']; $check = mysql_query("SELECT * FROM `inbox` WHERE `read`='0' AND `to`='$username'"); $inbox=mysql_num_rows($check); <TD width="4%" align="left" valign="middle"><span id="msgstatus"><span class="style2"> <?php if ($inbox > 0){ echo "<a href=inbox.php target=middle><img border=0 src=images/unread1.gif align=left width=16 height=11></a> "; }else{ echo "<img src=images/read.gif align=left width=16 height=11>"; } ?> </span></span></TD> The AJAX script is fine and tested, the guy who tested the script said there is something wrong with my php. is there anything wrong with my script? the above script basically displays one pic if there are unread messages in your inbox and if there aren't any then it displays a completely different picture.
  13. nope i have posted in php forum tho
  14. the inbox variable is set, i didnt include it before: $username=$_SESSION['username']; $viewuser=$_GET['viewuser']; $check = mysql_query("SELECT * FROM `inbox` WHERE `read`='0' AND `to`='$username'"); $inbox=mysql_num_rows($check); anything wrong with that?
  15. are you sure this script works with php and mysql databases?
  16. yes it is my php which is wrong, hmmm <TD width="4%" align="left" valign="middle"><span id="msgstatus"><span class="style2"> <?php if ($inbox > 0){ echo "<a href=inbox.php target=middle><img border=0 src=images/unread1.gif align=left width=16 height=11></a> "; }else{ echo "<img src=images/read.gif align=left width=16 height=11>"; } ?> </span></span></TD> whats wrong with the above code then? i can't figure it out
  17. nope doesnt work it doesn't alert when a new message comes, when i manually refresh the frame the new message sign shows. When i read it the sign dissapears. does this mean the script is partially working?
  18. it doesnt seem to work, perhaps you can look at the code and tell me why: <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel=stylesheet href=includes/in.css type=text/css> <style type="text/css"> <!-- .style2 {font-size: 12} .style3 {font-size: 11px} --> </style> <html> <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); setTimeout("sendRequest()", 1000); } 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; } } } window.onload=function() { sendRequest('message.php'); // replace "inbox-status.php" with your php page's url } </script> </head> <body> <TABLE width="110%" height="10" border="0" cellPadding="0" cellSpacing="0" bordercolor="#737373" class="thinline" id="Table1" style="LEFT: 0px; POSITION: absolute; TOP: 0px; height: 100%;" name="Table1"> <TR valign="middle"> <TD width="4%" align="left" valign="middle"><span id="msgstatus" class="style2"> <?php if ($inbox > 0){ echo "<a href=inbox.php target=middle><img border=0 src=images/unread1.gif align=left width=16 height=11></a> "; }else{ echo "<img src=images/read.gif align=left width=16 height=11>"; } if ($inbox > 0){ echo "<span style=FONT-WEIGHT:bold><a href=inbox.php ONMOUSEOUT=\"javascript:document.location.reload();\" target=middle><font color=#990066>$inbox New </a></font></span>"; } ?> </span></TD> <td width="96%" bgcolor="#737373"></td> </TR> </TABLE> </body> </html>
  19. how often does the script reload? how do i change this timer?
  20. i know, but where do i place it? i am tottaly confused
  21. Hi, currently i have the following php code: <?php if ($inbox > 0){ echo "<a href=inbox.php target=middle><img border=0 src=images/unread1.gif align=left width=16 height=11></a> "; }else{ echo "<img src=images/read.gif align=left width=16 height=11>"; } if ($inbox > 0){ echo "<span style=FONT-WEIGHT:bold><a href=inbox.php target=middle><font color=#990066>$inbox New </a></font></span>"; } ?> all it does it display whether user has new message in inbox or not. however currently i am using <META http-equiv="refresh" content="10"> to refresh the whole frame. how can i use AJAx to refresh the data from the mysql database without reloading the whole frame? thanks
  22. 1) its like the "$" sign is replaced by a question mark in a black diamond. 2) i'll find example 3) basically how do i echo something and have it displayed on a totally new page instead of on top of the current page the script shows? any clearer?
  23. Some small questions i need to know the answers for: 1) On my site the "$" is always replaced by the "?" sign. Its annoying and last time it happened i hired a guy to fix it, which he did. Any solutions i can try instead of paying him again to fix it? 2) anyway to hide the url for a link in the status bar and the address bar? for example instead of it saying www.hotmail.com/inbox.php it just says www.hotmail.com in the address bar? 3) how do i echo something on a new page? so if i had a script and its results would make the script echo a pic, how could i get it to echo it on a new page? 4) urm thats it lol
×
×
  • 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.