...

View Full Version : Syntax error with an else statement



Fishhead
02-02-2010, 06:19 AM
This parse error is driving me nuts and I need some better eyes than I have. Here the message:


Parse error: syntax error, unexpected T_ELSE in

I can not see any unmatched brakets, missing semicolons, etc. If I remove the there lines of code around the else it runs fine without the second condition. I tried removing the condition and simply having the else and the expression, but that does not help. Any suggestions?


while($qp_holder_count < $count){
$qp_holder_count = $qp_holder_count + 1;

$row_quotapounds = mysql_fetch_row($quotapounds);
$row_qp_max = mysql_fetch_row($qp_maximum);

$times = 29;
$x = 0;
while($x < $times){

if($row_quotapounds[$x] <= $row_qp_max[$x]);{
$species[$x] = $row_quotapounds[$x];
}

///////////// Trouble spot ////////////
else($row_quotapounds[$x] > $row_qp_max[$x]);{
$species[$x] = $row_qp_max[$x];
}

$ID = $species[0];
$totalgf = $species[1];
$ling = $species[2];
$Pcod = $species[3];
$hake = $species[4];
$sablen = $species[5];
$sables = $species[6];
$pop = $species[7];
$widow = $species[8];
$canary = $species[9];
$chili = $species[10];
$boc = $species[11];
$splitnose = $species[12];
$yt = $species[13];
$ssn = $species[14];
$sss = $species[15];
$lsn = $species[16];
$cow = $species[17];
$darkb = $species[18];
$ye = $species[19];
$shelfn = $species[20];
$slopen = $species[21];
$shelfs = $species[22];
$slopes = $species[23];
$dover = $species[24];
$english = $species[25];
$pet = $species[26];
$arrow = $species[27];
$starry = $species[28];
$otherflats = $species[29];
$x = $x + 1;
}


mysql_select_db($database_connifq, $connifq);
mysql_query("INSERT INTO qp_roll_over (ID, totalgf, ling, Pcod, hake, sablen, sables, pop, widow, canary, chili, boc, splitnose, yt, ssn, sss, lsn, cow, darkb, ye, shelfn, slopen, shelfs, slopes, dover, english, pet, arrow, starry, otherflats) VALUES('$ID', '$totalgf', '$ling', '$Pcod', '$hake', '$sablen', '$sables', '$pop', '$widow', '$canary', '$chili', '$boc', '$splitnose', '$yt', '$ssn', '$sss', '$lsn', '$cow', '$darkb', '$ye', '$shelfn', '$slopen', '$shelfs', '$slopes', '$dover', '$english', '$pet', '$arrow', '$starry', '$otherflats')")or die(mysql_error());
}

abduraooft
02-02-2010, 06:23 AM
if($row_quotapounds[$x] <= $row_qp_max[$x]);{
$species[$x] = $row_quotapounds[$x];
}

///////////// Trouble spot ////////////
else($row_quotapounds[$x] > $row_qp_max[$x]);{
$species[$x] = $row_qp_max[$x];
} I think you meant

if($row_quotapounds[$x] <= $row_qp_max[$x]){
$species[$x] = $row_quotapounds[$x];
}
elseif($row_quotapounds[$x] > $row_qp_max[$x]){
$species[$x] = $row_qp_max[$x];
} there

PS:
if(some condition);{
//do something
} is equivalent to

if(some condition)
;//do nothing
{
//do something (always!)
}

Fishhead
02-02-2010, 06:30 AM
That does it. Tomorrow I make an appointment with the eye doctor.

Thank you much.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum