Mi sono imbattuto in questi errori:
Notice: Undefined index: Nome in C:\xampp\htdocs\test2\test\zzz\pagination2\cerca6. php on line 75
Notice: Undefined index: Numero in C:\xampp\htdocs\test2\test\zzz\pagination2\cerca6. php on line 76
Notice: Undefined index: city in C:\xampp\htdocs\test2\test\zzz\pagination2\cerca6. php on line 77
Premetto che ho già cercato qui le soluzioni, ma per qualche ragione mi dà problema di sintassi.
1 . http://stackoverflow.com/questions/5...d-index-in-php
2 . http://stackoverflow.com/questions/1...ined-index-why
Il problema non è quando effettuo una query, ma quando clicco sulle pagine 1 o 2.
Da quello che ho capito non si tratta proprio di un errore, ma di disabilitare le notifiche. Io ho provato le loro soluzioni, ma per il mio codice mi dà errore di sintassi Parse error: syntax error..
Come devo modificare il codice per evitare queste fastidiose notifiche? O si tratta di un vero e proprio errore che ho nel codice?
Codice:
Codice PHP:
<head>
<style type="text/css">
a:link {text-decoration: none; color: brown;}
a:visited {text-decoration: none; color: green;}
a:hover {color: red;}
</style>
<style>
tr:nth-of-type(odd) { background-color: AZURE; }
tr:nth-of-type(even) { background-color: CYAN; }
</style>
<style>
tr:hover{background-color:DEEPSKYBLUE;}
</style>
<link rel="stylesheet" href="style.css" type="text/css" id="" media="print, projection, screen" />
<script type="text/javascript" src="jquery-latest.js"></script>
<script type="text/javascript" src="jquery.tablesorter.js"></script>
<script type="text/javascript">
$(function() {
$("table").tablesorter({debug: true});
});
</script>
</head>
<form action="cerca6.php" method="POST">
[b]Nome[/b]<input type="text" name="Nome">
[b]Numero[/b]<input type="text" name="Numero">
[b]city[/b]<input type="text" name="city">
<input type="Submit">
</form>
<?php
echo "<table id='rowspan' cellspacing='0' class='tablesorter'>";
echo "<thead><tr>";
echo "<th>[i]ID<i/></th>";
echo "<th>[i]Artista + Album<i/></th>";
echo "<th>Genere</th>";
echo "<th >Download</th>";
echo "</tr></thead>";
define('DB_NAME', 'forms1');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected) {
die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
}
mysql_query('SET CHARACTER SET utf8');
$per_page = 5;
$pages_query = mysql_query("SELECT COUNT(`Autore`) FROM `demo`");
$pages = ceil(mysql_result($pages_query, 0) / $per_page);
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
$start = ($page - 1) * $per_page;
$Nome = str_replace(' ', '%', $_POST['Nome']);
$Numero = str_replace(' ', '%', $_POST['Numero']);
$city = str_replace(' ', '%', $_POST['city']);
$arNome = str_split($Nome);
$arNumero = str_split($Numero);
$arcity = str_split($city);
$Nome='';
foreach ($arNome as $value)
{
if ($value=='%') continue;
$Nome.=$value.'%';
}
$Numero='';
foreach ($arNumero as $value)
{
if ($value=='%') continue;
$Numero.=$value.'%';
}
$city='';
foreach ($arcity as $value)
{
if ($value=='%') continue;
$city.=$value.'%';
}
$sql = mysql_query("SELECT * FROM demo WHERE Autore LIKE '%$Nome%' AND Titolo LIKE '%$Numero%' AND cit LIKE '%$city%' ORDER BY Autore LIMIT $start, $per_page") or die(mysql_error());
$i = 0; while($row=mysql_fetch_array($sql)){
$i++;
echo "<tr>";
echo "<td width='auto' bgcolor=”#FF0000 ″>" . "". "[b]" . $i . "". "<b/>". "</td>";
echo "<td width='auto'>" . "" . $row[1] . "" . "</td>";
echo "<td width='auto'>". $row[2] . "</td>";
echo "<td><a href=\"".$row[3]."\">".$row[3]."</a></td>";
echo "</tr>";
}
if ($pages >= 1 && $page <= $pages) {
for ($x=1; $x<=$pages; $x++) {
echo ($x == $page) ? '[b][url="?page='.$x.'"]'.$x.'[/url][/b] ' : '[url="?page='.$x.'"]'.$x.'[/url] ';
}
}
mysql_close();
?>