Jump to content

gaza165

Members
  • Posts

    472
  • Joined

  • Last visited

    Never

Everything posted by gaza165

  1. ok here it is im using JQuery... <?php // Report all PHP errors error_reporting(E_ALL); header("Expires: Mon, 26 Jul 1987 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); include ('../dbconnect/dbconnect.php'); $nick = $_GET['nick']; $message = $_GET['message']; $lastid = $_GET['lastid']; if ($lastid == 0) { $sql = "SELECT MAX(chat_id) FROM chat"; $res = mysql_query($sql); $lastid = mysql_fetch_row($res); $lastid = $lastid[0]; // Debug //echo "last id is ".$lastid; } $time_start = microtime(true); $sql = "SELECT * FROM chat WHERE chat_id > $lastid "; $result = mysql_query($sql); $time_end = microtime(true); $time = ($time_end - $time_start); $sql = "SELECT MAX(chat_id) FROM chat"; $res = mysql_query($sql); $lastid = mysql_fetch_row($res); $lastid = $lastid[0]; $data = array(); while ($row = mysql_fetch_array($result)) { $data[] ='{ "id": "'.htmlentities($row['chat_id']).'","nick":"'.htmlentities($row['nick']).'","message":"'.htmlentities($row['message']).'","time":"'.$time.'"}'; } $json = '{"latest":"'.$lastid.'","response":['; $json .= implode(',',$data); $json .= ']}'; echo $json; ?> and her is the js file $(document).ready(function(){ var id = 0; this.id = id; setInterval(function getShoutBox() { $.getJSON("ajax/ajaxgetshoutbox.php?lastid=" + id, function(json){ id = json.latest; $.each(json.response, function (i, item){ $("#container").append( "<ul>" + "<li><h2>" + item.nick + ":</h2><p>" + item.message +"</p></li>" + "</ul>" ); if(i == 0) { $("#sound_player").load("http://www.thedesignmonkeys.co.uk/content/chat.mp3"); } }); var divObject = document.getElementById('container'); divObject.scrollTop = divObject.scrollHeight; }); },5000) function submitMessage(){ $.ajax({ type: "POST", url: "ajax/send_message.php", complete: function() { $("#message").val(""); $("#message").focus(); }, success: function() {$("#send_message").val("Post Comment"); }, data: { nick: $('#nick').val(), message: $('#message').val() } }); } $("#send_message").click(function () {submitMessage(); }); });
  2. I find that it only seems to cut out when someone else is trying to post a comment.. if i keep adding comments it works fine. i have turned error_reporting on so if it does error it will tell me!! can someone go on it and test it for me and tell me where it lags out!! t Thanks Garry
  3. Hello everyone, i have built a shoutbox with PHP/JSON/AJAX/JQUERY. It works fine for a number of comments and then just randomly stops after that no messages come up or anything!! is this to much for the server and the database to handle to try it http://www.thedesignmonkeys.co.uk/new scroll down to submit comment and the form will appear you will soon see what i mean Thanks Garry
  4. <html><head><title>AJAX Search</title> <script src="js/jssearch.js"></script> <style type="text/css"> #users { width: 500px; height:100%: margin:0 auto; background: white; } #content { position:absolute; left:0px; top:0px; z-index:-1 } </style> </head> <body> <div id="users"> <input type=text name=search-username /> <input type="submit" onclick="search(this.value);"/> <div id="txtHint"></div> </div> <div id="content"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vel dolor. In sit amet augue. Suspendisse eleifend leo at diam. Phasellus luctus. Duis blandit tristique est. Suspendisse elit. Proin vitae neque at nibh tempus sollicitudin. Pellentesque condimentum nulla. Nulla lacus libero, convallis vel, fringilla at, rutrum ac, sem. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse pellentesque, ante ut aliquam porta, nisl massa pellentesque quam, eu semper magna dui vel quam. Quisque iaculis eros nec nibh. Donec placerat, ipsum et commodo rhoncus, nulla orci semper enim, non dapibus elit felis quis pede. Phasellus non sem. Ut lacus lacus, semper quis, rutrum et, placerat eu, nulla. Fusce eu purus. In hac habitasse platea dictumst. Quisque molestie orci non metus. Donec vestibulum sem sed pede. Donec in purus ut urna gravida iaculis. Donec vulputate imperdiet nulla. Ut semper ultricies pede. Curabitur non augue. Ut pharetra, lorem et sollicitudin dictum, pede tortor dictum massa, nec suscipit nisi odio at nisi. Nulla metus leo, porta vitae, auctor eu, interdum vitae, magna. Vivamus diam. Suspendisse potenti. Vivamus rutrum convallis ante. Sed quis lacus quis nisl aliquam elementum. Mauris mattis nulla a diam. Curabitur mattis. Maecenas egestas scelerisque augue. Donec bibendum dignissim augue. Aliquam ultrices rutrum felis. Nunc scelerisque eros ac lorem. Maecenas imperdiet lobortis purus. Mauris a leo in nisl posuere dictum. Pellentesque lacinia iaculis dui. Quisque ornare pede ac nisi. Suspendisse potenti. Nulla consequat auctor diam. Etiam suscipit. Nulla facilisi. Nulla facilisi. Morbi congue, urna ullamcorper vestibulum varius, metus neque fermentum quam, in egestas orci tortor eget pede. Etiam risus lacus, faucibus et, aliquet nec, lobortis vitae, diam. Etiam vestibulum. Curabitur sit amet massa. Suspendisse vel orci. Vestibulum vel leo. Aliquam erat volutpat. Aliquam erat volutpat. Mauris auctor odio sit amet nunc. Vestibulum congue vehicula neque. Quisque a massa sed tellus bibendum molestie. Sed elit. Nam ut mi quis est volutpat iaculis. Quisque viverra, nisi mattis varius tincidunt, mauris risus tempor sem, nec luctus tellus felis id nisl. Donec porta ligula a enim. In aliquam mattis ipsum. Aliquam libero lacus, consectetur ultricies, tempus id, vulputate non, urna. Vivamus in justo. Aenean mollis nisi nec turpis. Cras velit nisl, eleifend a, sodales non, facilisis at, lorem. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed volutpat pretium nulla. Pellentesque eros ligula, sagittis et, aliquet vel, volutpat at, turpis. Etiam dignissim ligula in quam. Donec blandit risus sit amet nibh. Suspendisse tincidunt urna non ante. Morbi iaculis auctor eros. Quisque egestas magna imperdiet dui. Quisque risus. Vivamus fringilla odio eget erat. Ut scelerisque dui. Nam sodales. Nulla facilisi. </div> </body> </html> you need to use something called z-index , take a look at that code and see what you think.
  5. <html><head><title>AJAX Search</title> <script src="js/jssearch.js"></script> <style type="text/css"> #left { width: 200px; float: left;} </style> </head> <body> <div id="left"> <input type=text name=search-username onkeypress="search(this.value);" /> <div id="txtHint"></div> </div> hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh </body> </html> this really depends what you want the site to look like... this is just an example...
  6. i would look into css to style your page to make it fit what you are trying to do.
  7. Crayon is absolutly right!!
  8. im confused, what do you need quotation marks around, the array $classes[$i][0] ???? are u passing a variable to the delete function??
  9. Change your sql statement too <?php $sql = "SELECT * FROM people GROUP BY datetime ASC"; $show = @mysql_query($sql,$connection) or die(mysql_error()); while ($row = mysql_fetch_array($show)) { $head_date = strtotime($row['datetime']); echo date('m-d-Y',$head_date); echo $row['fullname'].' - '.$row['datetime']; echo "<br>"; } ?>
  10. is the code you gave me the full code for the redirect??
  11. what url is it redirecting to? is a set url? or just a random one? explain what you are trying to do fully.
  12. <?php session_start(); function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } $_SESSION['url'] = curPageURL(); ?> the code above gets the current url for which you are on, then it will store it to a session variable then on redirect do the following code this will be on the page it is redircted to... <?php session_start(); echo $_SESSION['url']; ?>
  13. some code would be nice, how about using sessions to store the previous url on the redirect??
  14. Im not 100% about this but try looking into cURL Garry
  15. posting some code would be helpful to give us an idea of the setup. remember to use code tags....
  16. In order to keep the fields in the text boxes you will need to store the post data in sessions, so when the page is posted it is redirected back to the form. The value of the input will be the value that was posted orginally...
  17. i currently have an array of numbers and am outputing them like so 5,78,6,98,76,4,45, what i want to do is remove the last comma from the final item in the array 5,78,6,98,76,4,45
  18. Sorry thorpe, i will have a hunt else where. thanks for all your help...
  19. int[] Reverse(int[] Nums) { int[] temp; int size = Nums.length; int i = size; int counter = 0; for (;i>=0;i--) { temp[counter] = Nums[i]; counter++; } return(temp); } it returns an error saying.... "The local variable temp may not have been initialized"
  20. LOL... I do appreciate the help but was wondering if you could take a look at this code int[] SortDescending(int[] Nums) { int i, j; int Size = Nums.length; int Next; for (i = 1; i < Size; i++) { Next = Nums[i]; for (j = i - 1; (j >= 0) && (Nums[j] < Next); j--) { Nums[j + 1] = Nums[j]; } Nums[j + 1] = Next; } return(Nums); } int[] Reverse(int[] Nums) { int i; int Size = Nums.length; for(i = 9 - 1; i >= 0; i--) { Nums[i] = Nums[i]; } return(Nums); } is there any reason as to why the Reverse function would not work??
  21. Sure, i am working from another language called Processing 1.0, i am trying to write this method for Processing but want to figure it out in PHP first so then i can adapt it to work in my processing application.... So now i have that working..... now what i need the another method to do is to take these array of numbers and reverse it... so..... 23,41,3,56,42,9,82,56,29 needs to be 29,56,82,9,42,56,3,41,23 ??? how can i edit this
  22. I have an array of numbers and am trying to create a function to sort those numbers into order... but as part of my university practical i have been asked to make the sort function myself isntead of using phps built in sort function... this is what i have so far <?php $numbers = array(23,41,3,56,42,9,82,56,29); function sortAscending($Nums) { for ($i = 1; $i < Size; $i++) { $Next = $Nums[$i]; for ($j = $i - 1; ($j >= 0) && ($Nums[$j] > $Next); $j--) { $Nums[$j + 1] = $Nums[$j]; } $Nums[$j + 1] = $Next; } return($Nums); } print_r(sortAscending($numbers)); ?> any ideas as to where im going wrong.... thanks
  23. void setup() { int i; String OutPutLine = ""; PFont font; String[] Strs; int Size; int[] Nums; int Sum; font = loadFont("Calibri-48.vlw"); textFont(font); background(255, 255, 0); fill(0, 0, 0); Strs = loadStrings("Input.txt"); Size = Strs.length; size(800,800); Nums = new int[size]; for (i = 0; i < Size; i++) { Nums[i] = int(Strs[i]); } PrintArray(Nums,20); PrintArray(SortArray(Nums),50); } void PrintArray(int[] Vals, int Down) { int i; int L = Vals.length; String OutPutLine = ""; for (i = 0; i < L; i++) { OutPutLine += str(Vals[i]) + ","; } text(OutPutLine,10,Down * 3); } // PRE TRUE // POST RETURNS array whose elements are those of // Nums sorted into ascending order int[] SortArray(int[] Nums) { int i, j; int Size = Nums.length; int Next; for (i = 1; i < Size; i++) { Next = Nums[i]; for (j = i - 1; (j >= 0) && (Nums[j] > Next); j--) { Nums[j + 1] = Nums[j]; } Nums[j + 1] = Next; } return(Nums); } i have an array of numbers from a text file... i have to write methods to print out these numbers in ascending, descending and write them to text files. 23, 41, 3, 56, 42, 9, 82, 56, 29 3,9,23,29,41,42,56,56,82 i can do this but then i need it to do 29,56,82,9,42,56,3,41,23 - so the reverse of its orginal form..... can someone help me to write my method??? Thanks
  24. The POST Variable that is looking for is the name of your hidden input change your hidden input's name to which_month... <form name="pickmonth" method="post" action="editcurrent.php"><input type="hidden" name ="which_month" value="<?php echo $row['which_month']; ?>"/> <input type="submit" value="Edit"/></form>
  25. <?php $query = mysql_query("SELECT COUNT(*) FROM `bidding_details` where bid_id='$bid_id' and username='$username'") or die(mysql_error()); $count = mysql_result($query, 0); echo $count; //if($count < 5) { // header("location:product_detailframe.php?msg=11&&bid_id=$bid_id"); // exit; //} ?> echo out your count to see how many rows you are getting before the header executes... let me know what it gives out
×
×
  • 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.