View Full Version : Ugh huge error XD

03-09-2007, 07:06 PM
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

include "config.php";

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

//add rest of events here

for($s=1; $s<12; $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++){

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


//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");
if($number == "0"){


//this loop runs once for each show entry

case '0':
case '1':
case '2':

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.';


03-09-2007, 07:08 PM
Missing end quote?

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

03-09-2007, 07:11 PM
eee I see that now, I fixed it, but still have that error.

03-10-2007, 08:28 AM
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:

("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.

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:
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!