Note that there are some explanatory texts on larger screens.

plurals
  1. POCounter php-js doesn't update in the database
    text
    copied!<p>I made a counter that counts from one to infinity and if I refresh the page it doesn't stop.<br> However I have used ajax to update some datas in the database and this isn't working well ...<br> I think the problem is thet the ajax file dosn't run </p> <p><strong>HTML :</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;?php include "config.php"; ?&gt; &lt;script type="text/javascript"&gt; function createXMLHttpRequest(){ var ua; if(window.XMLHttpRequest) { try { ua = new XMLHttpRequest(); }catch(e) { ua = false; } }else if(window.ActiveXObject) { try{ ua = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e) { ua = false; }} return ua;} var some = createXMLHttpRequest(c); function some1(){ some.open('GET', 'Untitled_4.php?value='+c); some.onreadystatechange = hand; } function hand() { if(some.readyState == 4) { some.send(null); } } var c= &lt;?php $c= mysql_fetch_array( mysql_query("SELECT * FROM `clock` WHERE `id`=1")); $l=time()-$c['time']; $a=$l/1; $a=floor($a); $a=$a+$c['value']; echo $a; ?&gt;; var t; var timer_is_on=0; function timedCount() { document.getElementById('txt').innerHTML=c; c=c+1; t=setTimeout("timedCount()",1000); } function doTimer() { if (!timer_is_on) { timer_is_on=1; timedCount(); } } &lt;/script&gt; &lt;/head&gt; &lt;body onunload="some1(c)" onload="doTimer()"&gt; &lt;form&gt; &lt;div id="txt" &gt;&lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>AJAX File :</strong></p> <pre><code>&lt;?php include "config.php"; $value=$_GET['value']; mysql_query("UPDATE `clock` SET `time`=".time().",`value`= $value WHERE `id` = 1 "); echo "1"; ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload