ciao ragazzi...stamattina mi sono svegliato e volevo fare la simulazione di una partita di calcio semplice semplice...però dopo che ho scritto tutto...mi da un errore Parse error
unexpected $end in C:\www\pratita_improved.php on line 159
e nell'ultima riga c'è solo ?> che chiude il php...che devo fare'
Codice PHP:
<?php require_once('Connections/Goleada.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
//end
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
//end
mysql_select_db($database_Goleada, $Goleada);
$query_Recordset1 = "SELECT Cognome FROM giocatore,squadra WHERE Finalizzazione > 6 && squadra.Nome_Squadra = 'FC PAC'";
$Recordset1 = mysql_query($query_Recordset1, $Goleada) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
//end
mysql_select_db($database_Goleada, $Goleada);
$query_team1 = "SELECT id_club FROM squadra WHERE Nome_Squadra = 'FC Pac'";
$team1 = mysql_query($query_team1, $Goleada) or die(mysql_error());
$row_team1 = mysql_fetch_assoc($team1);
$totalRows_team1 = mysql_num_rows($team1);
mysql_select_db($database_Goleada, $Goleada);
$query_team2 = "SELECT id_club FROM squadra WHERE Nome_Squadra = 'Hurricanes'";
$team2 = mysql_query($query_team2, $Goleada) or die(mysql_error());
$row_team2 = mysql_fetch_assoc($team2);
$totalRows_team2 = mysql_num_rows($team2);
//end
$colname_giocatore_rand = "-1";
if (isset($_GET['team1'])) {
$colname_giocatore_rand = $_GET['team1'];
}
mysql_select_db($database_Goleada, $Goleada);
$query_giocatore_rand = sprintf("SELECT Cognome FROM giocatore WHERE id_club = %s ORDER BY RAND() LIMIT 1;", GetSQLValueString($colname_giocatore_rand, "text"));
$giocatore_rand = mysql_query($query_giocatore_rand, $Goleada) or die(mysql_error());
$row_giocatore_rand = mysql_fetch_assoc($giocatore_rand);
$totalRows_giocatore_rand = mysql_num_rows($giocatore_rand);
$colname_fin = "-1";
if (isset($_GET['giocatore'])) {
$colname_fin = $_GET['giocatore'];
}
mysql_select_db($database_Goleada, $Goleada);
$query_fin = sprintf("SELECT Finalizzazione FROM giocatore WHERE Cognome = %s", GetSQLValueString($colname_fin, "text"));
$fin = mysql_query($query_fin, $Goleada) or die(mysql_error());
$row_fin = mysql_fetch_assoc($fin);
$totalRows_fin = mysql_num_rows($fin);
$colname_dist = "-1";
if (isset($_GET['giocatore'])) {
$colname_dist = $_GET['giocatore'];
}
mysql_select_db($database_Goleada, $Goleada);
$query_dist = sprintf("SELECT Distanza FROM giocatore WHERE Cognome = %s", GetSQLValueString($colname_dist, "text"));
$dist = mysql_query($query_dist, $Goleada) or die(mysql_error());
$row_dist = mysql_fetch_assoc($dist);
$totalRows_dist = mysql_num_rows($dist);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
FC PAC - HURRICANES
</p>
<form id="form1" name="form1" method="post" action="">
<?php
$team1=$row_team1['id_club'];
$team2=$row_team2['id_club'];
$i=0;
$attacco1=0;
$attacco2=0;
$nome1="SELECT Nome_Squadra FROM squadra WHERE id_club = '$team1'";
$nome2="SELECT Nome_Squadra FROM squadra WHERE id_club = '$team2'";
$gol1=0;
$gol2=0;
for($i=0;$i<90;$i++){
srand((double)microtime()*1000000);
$attacco= rand(0, 10);
if($attacco<=5){
echo "$nome1 in possesso di palla";
sleep (5);
$giocatore=$row_giocatore_rand['Cognome'];
echo " $giocatore\n prova il tiro!!!!";
$fin= $row_fin['Finalizzazione'];
$dist=$row_dist['Distanza'];
$tiro= $fin+$dist;}
if($tiro < 10){
srand((double)microtime()*1000000);
$gol= rand(0, 4);}
if($gol >3){
echo "GOOOOOOOOOOOOOOOOL!!!!!! $giocatore va in rete!!!!!!";
$gol1++;
$reti[$i]= $giocatore;}
else{
if($tiro >10 && $tiro<16){
srand((double)microtime()*1000000);
$gol= rand(0, 7);}
if($gol >3){
echo "GOOOOOOOOOOOOOOOOL!!!!!! $giocatore va in rete!!!!!!";
$gol1++;
$reti[$i]= $giocatore;}
else{
if($tiro >=16 && $tiro<18){
srand((double)microtime()*1000000);
$gol= rand(1, 10);}
if($gol >5){
echo "GOOOOOOOOOOOOOOOOL!!!!!! $giocatore va in rete!!!!!!";
$gol1++;
$reti[$i]= $giocatore;}
else{
if($tiro >18){
srand((double)microtime()*1000000);
$gol= rand(2, 10);}
if($gol >5){
echo "GOOOOOOOOOOOOOOOOL!!!!!! $giocatore va in rete!!!!!!";
$gol1++;
$reti[$i]= $giocatore;}
else{
echo "niente da fare! occasione sprecata!!"; }
echo $gol1;
echo $reti[$i];
}
?>
</form>
</p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
mysql_free_result($team1);
mysql_free_result($giocatore_rand);
mysql_free_result($fin);
mysql_free_result($dist);
?>