Jump to content

c_pattle

Members
  • Posts

    295
  • Joined

  • Last visited

Everything posted by c_pattle

  1. Thank you. Although I am having some trouble with my timestamp. When I try to print out the time stamp to the screen it just says "undefined". Am I doing anything wrong? var rand; // Setting the interval so that the function executes every 4 seconds setInterval(function(contentFeed) { rand = contentFeed.timeStamp; alert(rand); $.ajax({ type: "GET", url: "feed.php", success: function(data) { alert("success"); } }); }, 4000);
  2. I have some JavaScript that sends an AJAX request to the following PHP script every 4 seconds. The idea behind this is that every 4 seconds a new, randomly generate piece of content is loaded. This works fine in Firefox and Chrome, however when I test it in IE it seems to just load the same piece of content over and over again. I'm pretty sure there is nothing wrong with the script so could this be something to do with IE caching the first piece of content returned? Thanks for any help. $random_number = 0; $random_number = rand(1,6); if ($random_number == 1 ) { echo("<a href=\"\"><h4>Aliquam erat volutpat. Vivamus feugiat tempor quam, faucibus elementum.</h4><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vitae ante at erat tempor facilisis. Quisque blandit faucibus suscipit. Proin suscipit est sed. </p></a>"); } if ($random_number == 2) { echo("<a href=\"\"><h4>Quisque ac lacus nibh, ac semper ante. Sed imperdiet.</h4><p>Vestibulum aliquam pellentesque lacus quis mollis. Proin quis lobortis libero. Ut nec tempor lectus. Pellentesque habitant morbi tristique senectus et netus id. </p></a>"); } if ($random_number == 3) { echo("<a href=\"\"><h4>Suspendisse vestibulum dui augue, nec viverra erat. Proin id.</h4><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu sollicitudin elit. Cras mauris mi, luctus non luctus quis, tristique vitae turpis turpis duis. </p></a>"); } if ($random_number == "4") { echo("<a href=\"\"><h4>Vestibulum gravida elit posuere arcu.</h4><p>Phasellus sit amet rutrum purus. Cras vulputate pretium quam eleifend viverra. Morbi convallis eros ac tellus suscipit nec euismod nibh semper. In quam posuere. </p></a>"); } if ($random_number == "5") { echo("<a href=\"\"><h4>Vestibulum ante ipsum primis in.</h4><p>Aliquam consectetur aliquet libero. Mauris malesuada tortor eu ipsum mollis sit amet blandit erat sollicitudin. Cras consequat dui ac elit semper pharetra amet. </p></a>"); } if ($random_number == "6") { echo("<a href=\"\"><h4>Nam ornare, nisl non interdum aliquam, erat urna consequat elit, vel.</h4><p>Nulla ut libero est, eu convallis urna. Nullam fringilla mollis ligula, id fringilla enim sagittis non. Nunc lectus nunc, condimentum eget imperdiet massa nunc.</p></a>"); }
  3. There are two effects that I have seen on website and keep wondering how they have been achieved. The first is when you go on Facebook and you type a link into your status bar. Then Facebook will automatically get some information about that article. The second effect is something I have seen on twitter and other websites. If you scroll down to the bottom of the page it will detect this and then load more content. If anyone could link me to any article or tutorials explain how these effects have been done that would be great. Thanks for any help.
  4. Everyone works. For example when I view the source code for my feed the "article_type" has data in it but for some reason it isn't showing up at all.
  5. Sorry I just didn't want to post loads of code. Here is the full script below. Everything works fine except for those "article_type", "article_author"... $rss_sql = "select * from articles where article_verification=\"1\" order by article_number desc limit 0, 10"; $rss_rs = mysql_query($rss_sql, $mysql_conn); $xml = '<?xml version="1.0" encoding="US-ASCII"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <atom:link href="rss.xml" rel="self" type="application/rss+xml" /> <title>Professional Perspectives - RSS Feed</title> <link>http://www.pperspectives.co.uk</link> <description>the best industry-lead opinions, insights and forecasts - direct</description> <language>en-us</language>'; while($rss_array = mysql_fetch_array($rss_rs)) { $xml .= "<item><title><![CDATA[" . $rss_array['article_title'] . "]]></title> <link><![CDATA[index.php?skip=true&article=" . $rss_array['article_number'] . "]]></link><guid><![CDATA[index.php?skip=true&article=" . $rss_array['article_number'] . "]]></guid><description><![CDATA[" . str_replace("'", "", $rss_array['article_description']) . "]]></description> <article_type>" . $rss_array['article_type'] . "</article_type> <article_author>" . $rss_array['article_author'] . "</article_author> <article_author2>" . $rss_array['article_author2'] . "</article_author2> <article_company>" . $rss_array['article_company'] . "</article_company> </item>"; } $xml .= "</channel> </rss>"; $file= fopen("rss.xml", "w"); fwrite($file, $xml); fclose($file);
  6. Hi everyone. I have written a PHP script gets data from a MySQL database and attempts to convert it to an RSS feed. The problem I am having is that when I preview the feed the "article_type", "article_author", "article_author2" and "article_company" information is not showing up in the feed. Have I coded this wrong? Thanks for any help. while($rss_array = mysql_fetch_array($rss_rs)) { $xml .= "<item><title><![CDATA[" . $rss_array['article_title'] . "]]></title> <link><![CDATA[index.php?skip=true&article=" . $rss_array['article_number'] . "]]></link><guid><![CDATA[index.php?skip=true&article=" . $rss_array['article_number'] . "]]></guid><description><![CDATA[" . str_replace("'", "", $rss_array['article_description']) . "]]></description> <article_type>" . $rss_array['article_type'] . "</article_type> <article_author>" . $rss_array['article_author'] . "</article_author> <article_author2>" . $rss_array['article_author2'] . "</article_author2> <article_company>" . $rss_array['article_company'] . "</article_company> </item>"; }
  7. I was just wondering if this is a way that you can exclude certain rows from a MySQL query. For example if I have 10 records each with a unique id, is there anyway I can get all of the records except record 5? Thanks for any help.
  8. I was wondering if anyone knows a good way to check for an even number of each character in a string. For example if the string is "abbacc" then it will return true as there are two of each character. However if the string is "ababc" it will return false as there is only 1 c. Thanks for any help
  9. sorry I made a mistake, the function will just take one string and it just needs to work out if this is an anagram of any palindrome.
  10. I need to write a function which comes two strings to find out if string 1 is an anagram or a palindrome For example the function should return 1 for the argument "dooernedeevrvn", because it is an anagram of a palindrome "neveroddoreven". For argument "aabcba", your function should return 0. I'm not really sure where to start so if anyone has done anything similar then any help would be great. Thanks for any help.
  11. I want to to do this because at the moment I am using two queries to create this results. It would be more efficient to use just 1 query so I was wondering if it can be done this way.
  12. Yeah sure. For example if there is a table called "names" with the following data. idname 1frank 2james 3harry 4casey Then I may want to do a query where I list all the records but repeating record number 3. Therefore the result would be, 3 - Harry 1. Frank 2. James 3. Harry 4. Casey
  13. I was wondering if it is possible to perform the following query. Say I have a list of names each with an id number ranging from 1 to 10. Is it possible to perform a query where you list all of these records while repeating one records. For example could I do a query that lists record number 6 then 10, 9, 8, 7, 6 etc. Or another example would be listing record number 10, then 10, 9, 8, 7, 6 etc? Thanks for any help.
  14. yeah sure. include ("inc_db_connect.php"); $username = $_POST['pp_username']; $password = $_POST['pp_password']; $login_sql = "select * from pp_users where pp_username=\"" . $_POST['username'] . "\" and pp_password=\"" . $_POST['password'] . "\""; $login_rs = mysql_query($login_sql, $mysql_conn); $login_result = "false"; if ($login_rs) { $login_result = "true"; } echo $login_result;
  15. Great thanks for your help. Now another problem is the if statement. It is meant to check if the data returned from the server is equal to "true". However I am finding that even if it returns something else if still think it's "true" and performs the first part of the if statement. Can you see anything wrong with how I have coded it?
  16. I have the following AJAX request but I am getting an error when I run the script which says that the function "loadContent" is undefined. Does anyone know why this is happening? $.ajax({ type: "POST", url: "includes/inc_login.php", data: dataString, success: function(data) { if (data=="true") { $("#loading").show(); $('#lightbox_content').hide('slow', loadContent); function loadContent() { $('#login_content').show('slow', hideLoader); } function hideLoader() { $("#loading").hide(); } $("#login_content").append("<p>Login successful</p>"); } else if (data=="false") { $("#login_content").append("<p>Sorry the username and password did not much. Please try again or <a href=\"\">register here</a></p>"); } } });
  17. I was just wondering what is the best way to handle passwords using mysql and php. For example if a user is registering (creating a username and password) and then logging in using that password what is the must secure way to handle this. Is it okay to just use password like and other field? Thanks for any help.
  18. I've made such a stoopid mistake. I was using a $_GET in my PHP script instead of POST. Sorry to waste your time. All your help was gratefully received.
  19. Thanks for your help although I am still getting a few problems. It still doesn't seem to be returned any data. However I get no errors returned in the error console so I think maybe there is a problem with my php script. Here is my ajax request. Also I have just started using JQuery so feel free to point out if I am doing anything wrong (e.g could write better code). $("#search_submit").click(function() { var search_term = $("input#search").val(); var dataString = 'search_term='+ search_term; $("#loading_status").ajaxStart(function(){ $("#loading_status").html('<img src="loading.gif"/\> '); setTimeout(function(){ $("#loading_status").html('')},1000); }); $.ajax({ type: "POST", url: "update_location.php", data: dataString, success: function(data) { $('#lightbox_content').hide(); $('#login_content').show(); $("#login_content").ajaxComplete(function(event, request, settings){ $("#login_content").html(data); }); } }); return false; });
  20. Thanks for taking the time to right a lengthy post. It's been very helpful.
  21. Thanks, that was helpful and I will use that script. However I just want to know how to get data returned from the server in an AJAX resquest. For example if the PHP script returns "yes", how do I access that?
  22. I am trying to use jquery for my AJAX request but am having a bit of trouble. My AJAX works but I am not sure how to get the response from the PHP page. My PHP script echo's some text but I am not sure how to append this text. I am trying to use data but I'm not sure if that's right. My script is below. $("#search").change(function() { var searchterm = $("input#search").val(); var searchString = 'search_term='+ searchterm; $.ajax({ type: "POST", url: "update_location.php", data: searchString, success: function(data) { $('#search_bar_hints').append(data); } }); return false; });
  23. I am trying to use jquery for my AJAX request but am having a bit of trouble. My AJAX works but I am not sure how to get the response from the PHP page. My PHP script echo's some text but I am not sure how to append this text. I am trying to use data but I'm not sure if that's right. My script is below. $("#search").change(function() { var searchterm = $("input#search").val(); var searchString = 'search_term='+ searchterm; $.ajax({ type: "POST", url: "update_location.php", data: searchString, success: function(data) { $('#search_bar_hints').append(data); } }); return false; });
  24. Thanks, yeah I have the image already I just need help with the script to make it display.
×
×
  • 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.