PHP+MySQLの間違い探し
PHP+MySQLのプログラムなのですが
Parse error: syntax error, unexpected ')' in
C:****.php on line 47
が出ました。47行目を含むif文を見ても()の数は合ってて何所が間違ってるのかわかりません><
よろしくお願いします。
<?php
function delta($c,$a){
if(((strcmp($c,'c0') == 0) && ($a == 0)) || ((strcmp($c,'c50') == 0)
&& ($a == 100)) || ((strcmp($c,'c100') == 0) && ($a == 50)) ||
((strcmp($c,'c100') == 0) && ($a == 100)))
return 'c0';
else if(((strcmp($c,'c0') == 0) && ($a == 50)) || ((strcmp($c,'c50')
== 0) && ($a == 0)))
return 'c50';
else
// else if(((strcmp($c,'c0') == 0) && ($a == 100)) ||
((strcmp($c,'c50') == 0) && ($a == 50)) || ((strcmp($c,'c100') == 0)
&& ($a == 0))
return 'c100';
}
function lambda($c,$a){
if(((strcmp($c,'c0') == 0) && ($a == 0)) || ((strcmp($c,'c0') == 0)
&& ($a == 50)) || ((strcmp($c,'c0') == 0) && ($a == 100)) ||
((strcmp($c,'c50') == 0) && ($a == 0)) || ((strcmp($c,'c50') == 0) &&
($a == 50)) || ((strcmp($c,'c100') == 0) && ($a == 0)))
return 'null';
else if(((strcmp($c,'c50') == 0) && ($a == 100)) ||
((strcmp($c,'c100') == 0) && ($a == 50)))
return 'juice';
else
// else if((strcmp($c,'c0') == 100) && ($a == 100))
return 'juice_50';
}
$input=$_GET['input'];
$mylink=mysql_connect("localhost", "student", "student");
mysql_select_db("mydb", $mylink);
$myresult=mysql_query("select * from at3",$mylink);
while($myrow=mysql_fetch_array($myresult)){
$i=$myrow[0];
$state=$myrow[3];
}
$del = delta($state, $input);
$lam = lambda($state, $input);
$i++;
mysql_query("insert into at3 values($i,$input,'$lam','$del')",$mylink);
//mysql_query("insert into at3 values($input,'$lam','$del')",$mylink);
print "<table border=4>";
print "<caption class='capbig'>Vending machine</caption>";
print "<tr><th>id</th><th class='left'>input</th><th
class='center'>output</th><th class='right'>state</th></tr>";
$myresult=mysql_query("select * from at3",$mylink);
//$myresult=mysql_query("select * from grade order by id asc",$mylink);
while($myrow=mysql_fetch_array($myresult)){
print "<tr><td align=right>".$myrow[0]."</td><td align=right
class='left'>".$myrow[1]."</td><td align=right
class='center'>".$myrow[2]."</td><td align=right
class='right'>".$myrow[3]."</td></tr>";
}
print "</table>";
$myresult=mysql_query("select sum(input) from at3",$mylink);
while($myrow=mysql_fetch_array($myresult)){
$sales=$myrow[0];
}
$myresult=mysql_query("select count(input) from at3 where
input='50'",$mylink);
while($myrow=mysql_fetch_array($myresult)){
$coin50=$myrow[0];
}
$myresult=mysql_query("select count(input) from at3 where
input='100'",$mylink);
while($myrow=mysql_fetch_array($myresult)){
$coin100=$myrow[0];
}
$myresult=mysql_query("select count(output) from at3 where
output='juice_50'",$mylink);
while($myrow=mysql_fetch_array($myresult)){
$output50=$myrow[0];
}
$myresult=mysql_query("select count(output) from at3 where
output='juice'",$mylink);
while($myrow=mysql_fetch_array($myresult)){
$juices=$myrow[0];
}
$coin50=$coin50-$output50;
$sales=$sales-$output50*50;
$juices=$output50+$juices;
print "Total sales: ".$sales."<br>";
print "Number of sold juices: ".$juices."<br>";
print "Number of 50 coin: ".$coin50."<br>";
print "Number of 100 coin: ".$coin100."<br>";
//$myresult=mysql_query("select max(score), name from grade",$mylink);
//while($myrow=mysql_fetch_array($myresult)){
// print "<tr><th class='left'>Max.</th><td align=right
class='center'>".$myrow[0]."</td><td
class='right'>".$myrow[1]."</td></tr>";
//}
mysql_free_result($myresult);
mysql_close($mylink);
?>
お礼
できましたー ありがとうございます。 感謝です。