Jump to content

joecooper

Members
  • Content count

    358
  • Joined

  • Last visited

Community Reputation

0 Neutral

About joecooper

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  1. joecooper

    MySQL DateTime Insert

    $newtime = date("Y-m-d H:i:s", time() + 600); mysql_query("UPDATE rounds SET clock = $newtime WHERE `round`='$CurrentRound' ") or die(mysql_error()); //update DB This code is failing to add the current time (+10 mins) to the MySQL database. The cell in the database is datetime format. I had done this before, but upon rewriting the code, it has stopped working.
  2. joecooper

    Refreshing countdown makes it disappear.

    Sorry, here is the link http://82.145.36.70/ So other than that the script is fine? Is there not a way to have a refreshing function that gets a single value for the date from another page? Rather than reload the clock script each time?
  3. joecooper

    Jquery Refreshing - prevent direct access?

    I guess its not a big deal if they wanted to have a look.
  4. It is a countdown that eventually would get the new date to count down to from a MySQL query. But it can change often and needs to refresh every second. Live example: http://www.mp3joe.com Not sure why it keeps disapearing like it is. index.php: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <head> <script type="text/javascript">// <![CDATA[ $(document).ready(function() { $.ajaxSetup({ cache: false }); // This part addresses an IE bug. without it, IE will only load the first number and will never refresh setInterval(function() { $('#results').load('data.php'); }, 5000); // the "3000" here refers to the time to refresh the div. it is in milliseconds. }); // ]]></script> </head> <div id="results">Loading users...</div> data.php: <head> <link rel="stylesheet" href="jquery.countdown.css"> <style type="text/css"> #defaultCountdown { width: 240px; height: 45px; } </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.countdown.js"></script> <script type="text/javascript"> $(function () { var austDay = new Date(); austDay = new Date(austDay.getFullYear() + 1, 1 - 1, 26); $('#defaultCountdown').countdown({until: austDay}); $('#year').text(austDay.getFullYear()); }); </script> </head> <div id="defaultCountdown"></div>
  5. Hi, I am very new to JQuery, but supprised how easy it really is. I have a simple refresh script. Every second, data.php is called and populates a div tag. How do i stop people accessing data.php directly? So only in the JS. Thanks
  6. joecooper

    Best way to run 1000+ querys per page

    Ok Solved! Thanks a lot! will be back here later asking how to AJAX this script! haha.
  7. joecooper

    Best way to run 1000+ querys per page

    Thank you for your reply. I have changed a lot of code to only add the entries that have boats, chests, boxs, have been clicked. Empty boxes don't have an entry on the DB. I will work on AJAX to make it update only where needed, but thats a new thing for me, need to look in to it more, but was an ultimate goal. Yes I have a script to get load times, currently around a second to generate. The problem I am having at the moment is the code that generates the grid isn't displaying correctly. It displays with the grid always empty (as in, clickable) and when you click on one that has already been clicked, it will give the error message. So the code that processes the clicks is working fine, just the displaying. At the moment I have got a query to the database to get all the rows in the database. Then as it generates the grid, it checks if the current generating cell has a database entry. If it has an entry and that box has been clicked, it will display the clicked image. Although this isn't working. <?php //This file generates the grid for the users if (!isset($including)) die("direct access not permitted"); $including=true; include('config.php'); //Get jackpot info $sql="SELECT * FROM jackpot WHERE `id` = '1'"; $result=mysql_query($sql); $row = mysql_fetch_array( $result ); $prevamount = $row['prevamount']; // $query = "SELECT * FROM grid ORDER BY id ASC"; $result = mysql_query($query); $row = mysql_fetch_array($result); if (isset($_SESSION['loggedin'])){ //if the user has logged in - show the clickable grid if (isset($griderrormsg)){ echo("<center><span style='background-color:white;color:red;font-size:12'>$griderrormsg</span></center>"); //display error } $cell = 0; echo("<TABLE BORDER=3 RULES=NONE FRAME=BOX width='20' border='0' cellspacing='0' cellpadding='0'"); for($i=1; $i<=$gridlength; $i=$i+1){ echo "<tr>"; for($j=1; $j<=$gridwidth; $j=$j+1){ $CurrentCell = $i*$j; if($CurrentCell==$row['id'] && $row['clicked'] > 0){ //if the current cell exists in the database... $clicked = $row['clicked']; $hitby = $row['user']; $row = mysql_fetch_array($result); //Get next result from database }else{// current cell doesn't exist, leave as clickable $clicked = 0; } if ($clicked == "1"){ //if the cell was clicked echo("<td title='$j, $i'><img src='b.gif"); }elseif ($clicked == "2"){ //if the ship was hit echo("<td title='$j, $i - Hit by $hitby'><img src='h.gif"); }elseif ($clicked == "3"){ //if is chest echo("<td title='$j, $i - $prevamount btc won by $hitby'><img src='chest.gif"); }elseif ($clicked == "4"){ //if is click box echo("<td title='$j, $i - Click Box Found By $hitby'><img src='box.png"); }else{ echo("<td><a href='index.php?c=" .($i*$j) . "'><img src='g.gif"); } echo("' BORDER=0></td></a>"); } echo("</tr>"); } echo("</table>"); }else{ //if the user hasnt logged in, show read only grid //To do. } ?>
  8. joecooper

    PHP hangs when getting num rows

    I rewrote the query and now is working fine. Odd as this code used to work on a previous server. $result = mysql_query("SELECT * FROM grid WHERE id=$nextcell LIMIT 1"); if(mysql_fetch_array($result) == false){ } Thanks for your help.
  9. joecooper

    PHP hangs when getting num rows

    It also hangs when using: $sql="SELECT * FROM grid WHERE `id` = '$nextcell' LIMIT 1"; $result=mysql_query($sql); if (mysql_fetch_array($result)){ }
  10. I have this same code elsewhere and it runs without a problem Basically, the script wants to put some data in the database, but if the row already exisits, it needs to ignore it. I am using mysql_num_rows for this. $sql="SELECT * FROM grid WHERE `id` = $nextcell LIMIT 1"; $result=mysql_query($sql); $numrows = mysql_num_rows($result); if ($numrows=0){ //nothing here, input data //code to insert } It hangs on the 2nd line. I added "die("$nextcell");" to check it is returning a number, and it does.
  11. joecooper

    Best way to run 1000+ querys per page

    VERY sorry to revive this 2+ year thread. But I have reopened my site again (different domain). Back facing this problem. The database needs to hold the info for all of the cells as they contain other data such as if a boat is in that square, or a chest.
  12. joecooper

    Best way to run 1000+ querys per page

    Ah thanks for all your replys. Assumed i wouldnt get much more on this. I thought about using the image idea, but i have no idea how to create the links! perhaps using a simular method to www.milliondollarhomepage.com with coordinates. but im sure there will me so much more data. the table must have all 1088 rows as the round starts over every hour or so. so at the end of it it will reset itself. I have since moved the site to a VPS which has helped alot with the loading times
  13. joecooper

    Best way to run 1000+ querys per page

    Thanks alot PFMaBiSmAd! the loading times are still around 0.3 seconds though. Will have a look at what other code could be causing it.
  14. joecooper

    Best way to run 1000+ querys per page

    That would mean the same amount of entrys? Im unsure how to run 1 query and parse all the data, is there any example?
×

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.