SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Php Script problems Help Please.

    Okay, I am trying to fix a website I own, it is a pimp site located at http://www.pimpriots.com. (I cannot get script support I don't know who created it and I didn't buy the script it came with the site)

    The problem is the fields that records the number of attacks in and out seem to get updated by the 1 hour cron script to values like "4294967294" when really it should just minus some attack in/ out times from the field. At first I assumed it was a php version issue but I've tried version 4.6 , 5.3 and 4.3.11 and they don't make any difference.

    This is the 1hour.php script. (Look for attin and attout for reference).

    PHP Code:
    $getgames mysql_query("SELECT round FROM $tab[game] WHERE starts<$time AND ends>$time ORDER BY round ASC;");
    while (
    $game mysql_fetch_array($getgames))
    {
      if (!
    fetch("SELECT lastran FROM r$game[0]_$tab[cron] WHERE cronjob='cranks';"))
         { 
    mysql_query("INSERT INTO r$game[0]_$tab[cron] VALUES ('cranks','$time');"); }
    else { 
    mysql_query("UPDATE r$game[0]_$tab[cron] SET lastran='$time' WHERE cronjob='cranks'"); }

    mysql_query("UPDATE r$game[0]_$tab[pimp] SET attin=attin-1,  attout=attout-2 WHERE id>0;"); THIS LINE @@@@@@@@@

    $getcrewranks mysql_query("SELECT id FROM r$game[0]_$tab[crew] WHERE id>0 ORDER BY networth DESC;");
    $urank 0;
    while (
    $crws mysql_fetch_array($getcrewranks))
          { 
          
    $urank++;
          
    mysql_query("UPDATE r$game[0]_$tab[crew] SET rank=$urank WHERE id='$crws[0]';");
          }

    Also the database fields are set like this
    Code SQL:
      `attin` INT(10) UNSIGNED NOT NULL DEFAULT '0',
      `attout` INT(10) UNSIGNED NOT NULL DEFAULT '0',

    NOTE: I have removed the other script snippets because I don't believe they cause the problem because the strange numbers only load after the 1hour.php cron script is executed.

    I am stumped I cannot see anything that would cause the fields to be updated to such strange and irregular values ANY help would be greatly appreciated.

    Also no claim of copyright is in ANY of the scripts so I don't think it matters that I've posted bits of it here.

    THANK YOU FOR READING!
    Last edited by hawkal; Jun 22, 2007 at 03:03.

  2. #2
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,115
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    I don't know if people are going to be able to wade through that..

    It seems that the PHP forum is the one that attracts most post like "Here's a 9000 line Script.. Why is it broken?"
    There's too many people who write shonky php code - is the reason why it happens.

    A couple of things though:
    You shouldn't use variable replacement in strings like this:
    "SELECT round FROM $tab[game] WHERE starts<$time AND ends>$time ORDER BY round ASC;"

    Use concatenation, it will stop many errors that come with that method:
    "SELECT round FROM ".$tab['game']." WHERE starts < ".$time." AND ends > ".$time." ORDER BY round ASC;"

    Use the full <?php opening tags, not <?

    It's really really a mess..

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I just didn't know where else to ask, this php code goes deeper into php then my knowledge thus I am unable to interpret it properly. Also as far as im aware the script is quite old so it could be that it uses older conventions?

  4. #4
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,115
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    It's not your fault that you can't interpret it.. I can't interpret it either

    The accepted conventions have been around for a while now, it's more likely that the coder was just lazy and not terribly good at it..

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see, thanks again anyway.

  6. #6
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am new around here, but nevertheless may I suggest that a more descriptive title would be of assistance? "PHP script problems help please" could arguably apply to all posts in this forum - but isn't of much help when scrolling through a list of them. Succinct titles and well-phrased questions attract the most help, I find.

  7. #7
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One more thing i have to say, that since round is the MySQL keyword, you cannot use it as field name of the database table too as i know so far. I am not sure for what purpose you have used it here.

    Also i agree with halfer, that it would be better to be more descriptive in title as well as in the description around the problem.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  8. #8
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help everyone, I have fixed the problem.
    The problem was indeed this line.
    PHP Code:
    mysql_query("UPDATE r$game[0]_$tab[pimp] SET attin=attin-1,  attout=attout-2 WHERE id>0;"); 
    I just changed it by having it select the player (pimp) via a different field. Also I split it into two seperate queries one for attin and another for attout.

    Thanks again.

  9. #9
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,115
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    It would have been the variable replacement for these two variables methinks.. "r$game[0]_$tab[pimp]"

    I imagine this would have worked also:
    Code PHP:
    mysql_query("UPDATE ".r$game[0]."_".$tab['crew']." SET rank='".$urank."' WHERE id='".$crws[0]."'");


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •