i'm trying to put my php code that connects to my MySQL database directly in my HTML page, but something goes wrong when i try to see the page.. how can i solve the error "Fatal error: Maximum execution time of 30 seconds exceeded in /membri/bestparty/IOS/IOS/eventi.php on line 41"
if i try to remove one variable for example $festa[$i] the error persists.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="HandheldFriendly" content="True">
<meta http-equiv="cleartype" content="on">
<link rel="stylesheet" type="text/css" href="css/stile.css">
<meta name="viewport" content="width=320, initial-scale=0.7, user-scalable=no">
<script src="JS/jquery-1.11.1.js.js"></script> <!--PER EVENTI-->
<script src="JS/func.js"></script> <!--PER EVENTI-->
<title>BParty</title>
</head>
<body>
<?
$DBhost = "localhost";
$DBuser = "bestparty";
$DBpass = "";
$DBName = "my_bestparty";
$table = "Dati";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Impossibile collegarsi al server");
@mysql_select_db("$DBName") or die("Impossibile connettersi al database $DBName");
$sqlquery = "SELECT * FROM `Dati` ORDER BY Data DESC";
$result = mysql_query($sqlquery);
$number = mysql_num_rows($result);
$i = 0;
while ($i < 20) {
$festa[$i] = mysql_result($result,$i,"festa");
$luogo[$i] = mysql_result($result,$i,"luogo");
$idfesta[$i] = mysql_result($result,$i,"ID");
$data[$i] = mysql_result($result,$i,"data");
$foto[$i] = mysql_result($result,$i,"organizzatore");
}
?>
<div id="navigation">
<table width="100%">
<tr valign="middle">
<td valign="middle" width="25%" align="center">
<
</td>
<td valign="middle" width="50%" align="center">
BPARTY
</td>
<td width="25%" align="center">
>
</td>
</tr>
</table>
</div>
<div id="evntprg">
EVENTI IN PROGRAMMA
</div>
<div id="container" style="overflow:scroll;">
<? echo'
<!--INIZIO DIV EVENTO-->
<a href="http://www.bparty.org/IOS/IOS/pagevento.php?var=$idfesta[$i]">
<div style="width:90%; display:block; margin:0 auto;
padding-top:10px; margin-top:10px; padding-left:10px;
background-color:#FFF; padding-bottom:10px;
border-left:solid 8px #4D7C4F;">
<table width="100%" style=\'table-layout:fixed\'>
<tr valign="middle">
<td valign="middle" align="center" class="evntfoto"
style="background-image:url($foto[$i]);
background-position:center;
background-size: cover;">
</td>
<td valign="top" align="left" id="evnttxt">
<font color="#0066FF" size="+1"> <b> $festa[$i] </b></font> <br>
echo "$data[$i]" <br>
<font color="#585858"> $luogo[$i] </font> <br>
</td>
</tr>
</table>
</div></a>
<!--FINE DIV EVENTO-->
';
?>
</div>
</div>
</body>
</html>
--EDIT--
Ok, i solved this, but now.. why the html page shows me the variable as "$festa[$i]" and not for example "Lorem ipsum" ?
<?
$DBhost = "localhost";
$DBuser = "bestparty";
$DBpass = "";
$DBName = "my_bestparty";
$table = "Database";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Impossibile collegarsi al server");
@mysql_select_db("$DBName") or die("Impossibile connettersi al database $DBName");
$sqlquery = "SELECT * FROM `Database` ORDER BY data DESC";
$result = mysql_query($sqlquery);
$number = mysql_num_rows($result);
$i = 0;
while ($i < 20) {
$festa[$i] = mysql_result($result,$i,"festa");
$luogo[$i] = mysql_result($result,$i,"luogo");
$idfesta[$i] = mysql_result($result,$i,"ID");
$data[$i] = mysql_result($result,$i,"data");
$linkfoto[$i] = mysql_result($result,$i,"organizzatore");
echo'
<!--INIZIO DIV EVENTO-->
<a href="http://www.bparty.org/IOS/IOS/pagevento.php?var=$idfesta[$i]">
<div style="width:90%; display:block; margin:0 auto;
padding-top:10px; margin-top:10px; padding-left:10px;
background-color:#FFF; padding-bottom:10px;
border-left:solid 8px #4D7C4F;">
<table width="100%" style=\'table-layout:fixed\'>
<tr valign="middle">
<td valign="middle" align="center" class="evntfoto"
style="background-image:url($foto[$i]);
background-position:center;
background-size: cover;">
</td>
<td valign="top" align="left" id="evnttxt">
<font color="#0066FF" size="+1"> <b> $festa[$i] </b></font> <br>
echo "$data[$i]" <br>
<font color="#585858"> $luogo[$i] </font> <br>
</td>
</tr>
</table>
</div>
</a>
<!--FINE DIV EVENTO-->
';
$i++;
}
mysql_*. The extension has been deprecated for some time now. Switch tomysqlior ` PDO` instead. Also: don't mix DB code with markup, that's just bad practice. As is the use of the@operator of death. If a function generates a warning/error/notice: FIX IT, don't hush it up