Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ugh huge error XD

    I ge this error "Parse error: syntax error, unexpected T_VARIABLE in /home/colin/public_html/crons58745146/runshowscript.php on line 37" But I dont understand why? Can someone PLEASE help me XD

    PHP Code:
    <?php
    include "config.php";

    $tonightdate('2007-03-08);
    $event[1]="Obedience";
    $event[2]="Hunting";
    $event[3]="Conformation";
    $event[4]="Sporting";
    $event[5]="Flyball";
    $event[6]="Herding";
    $event[7]="Agility";
    $event[8]="Working";
    $event[9]="Racing";
    $event[10]="Show";
    $event[11]="Schutzhund";

    //add rest of events here

    for($s=1; $s<12; $s++){
    $showtype="$event[$s]";

    //this for loop runs once for every event

    $level[1]="Level 1";
    $level[2]="Level 2";
    $level[3]="Level 3";
    $level[4]="Level 4";
    $level[5]="Level 5";
    $level[6]="Level 6";

    //add rest of levels here

    for($l=1; $l<7; $l++){
    $showlevel="$level[$l]";


    $query=mysql_query("select showID,prize from shows where event='
    $showtype' and level='$showlevel' and rundate='$tonight'")or die(mysql_error());
    $num=mysql_num_rows($query);
    if($num == "0"){
    continue;
    }

    for($i=0;$i<$num;$i++){
    $showrow=mysql_fetch_array($query);

    //this loop runs once for every show 

    $entryquery=mysql_query("select entererID,dogID,score from show_entries where showID='
    $showrow[showID]' ORDER BY score DESC");
    $number=mysql_num_rows($entryquery);
    if($number == "0"){
    continue;
    }

    for($m=0;$m<$number;$m++){
    $entryrow=mysql_fetch_array($entryquery);

    //this loop runs once for each show entry

    switch($m){
    case '
    0':
    $points=250;
    $place=1;
    $prize=round($showrow[prize]/1);
    break;
    case '
    1':
    $points=200;
    $place=2;
    $prize=round($showrow[prize]/2);
    break;
    case '
    2':
    $points=150;
    $place=3;
    $prize=round($showrow[prize]/3);
    break;
    default:
    $points=50;
    break;
    }

    mysql_query("update dog set points=points+$points where dogID='
    $entryrow[dogID]'");

    if($m == "0" || $m == "1" || $m == "2"){
    mysql_query("update players set money=money+$prize where playerID='
    $entryrow[entererID]'");

    mysql_query("insert into show_places(showID,entererID,dogID,place,rundate)values('
    $showrow[showID]','$entryrow[entererID]','$entryrow[dogID]','$place','$tonight')");
    }
    }
    }
    }
    }
    mysql_query("delete from shows where rundate='
    $tonight'");
    mysql_query("delete from show_entries where rundate='
    $tonight'");

    echo '
    Successfully ran cron.;

    ?>

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Missing end quote?

    $tonight= date('2007-03-08);

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    eee I see that now, I fixed it, but still have that error.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I err... see no other 'syntactical' errors other than the second line there as already pointed out.
    However, you are looking at one hefty loop structure, you are on a 4th level inner loop, meaning you will have piss poor efficiency.
    Assuming you have 7 db entries (the full requested loop amount), and your fields are linked through the showID column, you are looking at about... 4116 (first 12, second 7, third 7, fourth 7) loop iterations if I'm not mistaken. Thats a lot of steps just to look up 7 entries.
    You may want to consider joining your queries as a more elegant method. Granted a join technically takes more query time, it will save you loads on your interpreter time:
    PHP Code:
    ("SELECT tblEvent.showID, tblEvent.prize, tblEntries.entererID, tblEntries.dogID, tblEntries.score
      FROM event AS tblEvent
      INNER JOIN show_entries AS tblEntries
      ON (tblEntries.showID = tblEvent.showID)
      WHERE tblEvent.event = '" 
    $showtype "' AND level = '" $showlevel "' AND rundate = '" $tonight "' ORDER BY tblEntries.score DESC"); 
    Will this work? I'm not certain, without data to compare to. However, your current queries indicate a grab for show_entries on each result from events.showID. So I would assume that is your table join. This instantly results in a drop of two of your loops, as you can use a while to evaluate a greater than 0 condition.
    PHP Code:
    while ($rows mysql_fetch_array($query))
    {

    Rows should contain all the information required from both the event and show_entries where the criteria is met.
    BTW, the criteria can be altered as well for your showLevel data. Currently, you have an iteration for each value of $showlevel and grab a result on each of those. This results in the first query being executed 7 times, the second 49 times, etc. etc. Instead, use a " level IN (" . implode(',', $level) . ") " to grab the necessary rows on a single query. That kills your 3rd inner loop. Same goes for your $showtype condition. This will kill all of your loops completely, but as mentioned, without sold data to work with, I cannot ensure this will actually suit your needs. Your new iteration value will be down to 12. Quite a savings indeed, this method would require a limit to be placed into your sql as well to control the number of entries.


    On a quick side note array and variable assignements like this:
    $showtype="$event[$s]";
    are not necessary. This puts extra strain onto the interpreter as it is also searching for text within the interpreted data. A better solution is to completely drop the quotations:
    $showtype = $event[$s];

    Good luck!
    Last edited by Fou-Lu; 03-10-2007 at 07:49 AM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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