My Custom Rack I Built
Reply to topic
 
bug in my script bur can't find it:(



Joined:03 Jun 2004
Posts:1
Reply with quote
There is some bug in my script, it's a javascript combined with php, well I'm quite sure the bugisn't in the php so maybe sm can take a look at it.
this is the script:
Code:


<?php
require('connect.php');
?>
<?php


 $query2 = "SELECT * FROM recruiter WHERE username='$username'";
$result2 = mysql_query ($query2)
  or die ("Query failed2");
$row2=mysql_fetch_array($result2);
$credits=$row2['credits'];

if($credits>=350){
$query3 = "UPDATE recruiter SET max='y' WHERE username='username'";
$result3 = mysql_query ($query3)
  or die ("Query failed3");

   $query4 = "SELECT * FROM recruiter WHERE username='$username'";
$result4 = mysql_query ($query4)
  or die ("Query failed2");
$row4=mysql_fetch_array($result4);
$max=$row4['max'];

  }

  if($credits<=350){
$query5 = "UPDATE recruiter SET max='n' WHERE username='username'";
$result5 = mysql_query ($query5)
  or die ("Query failed3");
  }


$querya = "SELECT stamp FROM recruiter WHERE username='$username'";
$resulta = mysql_query ($querya)
  or die ("Query failed1");
  $stamp=mysql_fetch_array($resulta);
  $time=time();
  $clicked=$time+3000;


  $query1 = "SELECT * FROM recruiter WHERE credits>0 AND stamp>$clicked ORDER BY credits DESC LIMIT 0 , 1";
$result1 = mysql_query ($query1)
  or die ("Query failed");
$row=mysql_fetch_array($result1);
$link1=$row['link'];


  ?>
 <style type="text/css">

<!--

a:link { text-decoration:none; font-weight:bold; color:#FFFF00; }

a:visited { text-decoration:none; font-weight:bold; color:#FFFF00; }

a:hover { font-weight:bold; color:#FF0000;  }

-->

</style>

<html>

<head>

<script language="JavaScript" type="text/javascript">

var Zeit = 20;

var durch = 0;

function doTime()

{if(document.formular.pause.checked==false){

        if (Zeit >= 0) {

Zeit--;

                document.formular.count.value = Zeit;

            aktiv = setTimeout('doTime()', 1000);}

    else clearTimeout(aktiv);

if (Zeit == 0) {

durch++;
<?php
if($max=='n'){
if($credits>=350){
$query6 = "UPDATE recruiter SET credits=credits+1 WHERE username='username'";
$result6 = mysql_query ($query6)
  or die ("Query failed3");
  }   }
  ?>

if (durch == 1000){

    window.location.reload()

}

parent.mainFrame.location.href=<?php echo $link1 ?>;

Zeit = 20;

};



}else aktiv=setTimeout('doTime()',1000);}



</script>

<meta name="author" content="&ocirc;2Ø">

</head>

<BODY onload="doTime()" BGCOLOR="#006699" TEXT="#ffffff" TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=2 MARGINHEIGHT=0>
 <?php
 echo $username;
 ?>
<td><form name="formular">

   <table width="969" border="0" height="64">

      <tr>

         <td width="268" height="1">

         </td>

         <td rowspan="4" width="94" height="58">

          <font face="Verdana">
          <a target="_blank" href="http://www.126hits.com/ads.htm">
          Buy Credits</a></font></td>

         <td rowspan="4" width="585" height="58">

          <div align="center">



      </div>

        </td>

      </tr>

      <tr>

        <td width="268" height="22"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">receive Credits in

          <input type="text" name="count" size="2" >

          Sec. </font></td>

      </tr>

      <tr>

      <td width="268" height="20">

      <input type="checkbox" name="pause" value="ON"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">stop Counter

      </td>

      </tr>

     


    </table>

  </form></td>

</body>

</html>


You can find an example here:
http://www.thelastalliance.net/recruiter/recruiter.php

when the counter reaches zero it's supposed to load a new link but it doesn't[/code]
View user's profileFind all posts by AJBSend private message
bug in my script bur can't find it:(

Site Admin

Site Admin

Joined:30 Apr 2000
Posts:2841
Location:Texas, USA
Reply with quote
your provided link [example on your site] can not connect to your database.

This code:
aktiv = setTimeout('doTime()', 1000);

could be written aktiv=setInterval("doTime()",1000);

this would just start a 1 second timer that you could kill if the pause button is pressed etc.

It looks like the javascript is in question and not the php [?]

Here is a javascript/html solution:
Code:

<html>
<head>
<style type="text/css">
a:link { text-decoration:none; font-weight:bold; color:#FFFF00; }
a:visited { text-decoration:none; font-weight:bold; color:#FFFF00; }
a:hover { font-weight:bold; color:#FF0000;  }
.wrap {
  background-color: white;
  border-width : 1px;
  border-color : #0000CC;
  border-style : solid;
}
.body { margin: 0px; padding: 0px; background-color: #FFFFFF; color: #004488; font-weight: normal; border-width: 0px; border-style: solid; border-color: #A0D3FF;}
</style>
<script language="JavaScript" type="text/javascript">
var Counter = 20; /* seconds to wait */
var AFTER_URL="http://js-x.com/"; /* where to send the user when the time expires */
var TIME=1*1000; /* 1 second */
var TIMER=null;
function stop()
{
  if(TIMER)
  {
    clearInterval(TIMER);
    TIMER=null;
  }
}
function start()
{
  stop();
  TIMER=setInterval("click()",TIME);
}
function click()
{
  if(!document.formular.pause.checked)
  {
    if ((document.formular.count.value=Counter--)<0)
    {
      stop();
    }
    if (!Counter)
    {
      document.location=AFTER_URL;
    }
  }
}
</script>
</head>
<BODY onload="start();document.formular.pause.checked=false;" onunload="stop()">
<form name="formular">
<table class=wrap align=center border="0" cellpadding=3 cellspacing=0>
<tr class=body>
<td>Wait for <input class=body type="text" name="count" size="2" >seconds.</td>
</tr>
<tr class=body>
<td>
<input type="checkbox" name="pause" value="ON">Pause Counter</td></tr>
</table>
</form>
</body>
</html>

_________________
Cheers.

-- Mike Robb

joker
View user's profileFind all posts by mikeSend private messageVisit poster's website
bug in my script bur can't find it:(
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
All times are GMT - 6 Hours  
Page 1 of 1  


  
  
 Reply to topic