anche a me da lo stesso errore solo che ho replicato database e sito su un PC prendendo il codice già funzionante da un altro.
Notice: Undefined offset: 3 in /opt/lampp/htdocs/progetto/index.php on line 52
Notice: Undefined offset: 4 in /opt/lampp/htdocs/progetto/index.php on line 52
sul Macbook di partenza usando Xampp non mi da problemi e non mi ha mai segnalato questo tipo di errori.
ho importanto il tutto su Linux Ubuntu sempre utilizzando come server locale Xampp e segnala quell' errore.
non ho proprio idea del perchè...
il mio codice è questo.
Codice PHP:
<?php
include_once('db_connect.php');
$query_ar= "SELECT artist, title FROM Record ORDER BY code DESC ";
$result_ar= mysql_query($query_ar)
or die("error ar");
while ($result_row_ar=mysql_fetch_row(($result_ar))){
$ar_array[]=$result_row_ar[1]." - ".$result_row_ar[0];
}
for($index=0; $index<5; $index++){
echo "[*]".$ar_array[$index]."";
}
?>
Codice PHP:
<?php
include_once('db_connect.php');
$query_random="SELECT userName FROM User";
$result_random=mysql_query($query_random);
if(!$result_random){
echo 'ERROR
';
die("Could not query the database
".mysql_error());
}
while ($result_row=mysql_fetch_row(($result_random))){
$artist_array[]=$result_row[0];
}
shuffle($artist_array);
for($index=0; $index<5; $index++){
echo "[*]".$artist_array[$index]."";
}
?>
Codice PHP:
<?php
include_once('db_connect.php');
$query_comment= "SELECT commentText, commentDate FROM Comment ORDER BY code DESC ";
$result_comment= mysql_query($query_comment)
or die("error");
while ($result_row_comment=mysql_fetch_row(($result_comment))){
$comment_array[]=$result_row_comment[1]." \"".substr($result_row_comment[0],0,150)."...\"";
}
for($index=0; $index<5; $index++){
echo "[*]".$comment_array[$index]."";
}
?>
Codice PHP:
<?php
include_once('db_connect.php');
$query_rm= "SELECT Record.title, Record.artist, AVG(Voting.vote) FROM Record JOIN Voting ON Record.code=Voting.record WHERE MONTH(Voting.votingDate)=MONTH(CURDATE()) GROUP BY Record.title ORDER BY AVG(Voting.vote) DESC ";
$result_rm= mysql_query($query_rm)
or die("error rm");
while ($result_row_rm=mysql_fetch_row(($result_rm))){
$rm_array[]=$result_row_rm[0]." - ".$result_row_rm[1]." - ".substr($result_row_rm[2],0,3);
}
for($index=0; $index<5; $index++){
echo "[*]".$rm_array[$index]."";
}
?>
Codice PHP:
<?php
include_once('db_connect.php');
$query_am= "SELECT artist, title FROM Record ORDER BY rating DESC ";
$result_am= mysql_query($query_am)
or die("error am");
while ($result_row_am=mysql_fetch_row(($result_am))){
$am_array[]=$result_row_am[1]." - ".$result_row_am[0];
}
for($index=0; $index<5; $index++){
echo "[*]".$am_array[$index]."";
}
?>