Salve ragazzi ho il seguente codice:
<?php
//Riceve l'identificativo di un regista e ne restituisce il nome completo
function get_director($director_id){
global $db;
$query='SELECT
people_fullname
FROM
people
WHERE
people_id='.$director_id;
$result=mysql_query($query,Sdb)or die (mysql_error($db));
$row= mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
//Riceve l'identificativo di un attore e ne restituisce il nome completo
function get_leadactor ($leadactor_id){
global $db;
$query='SELECT
people_fullname
FROM
people
WHERE
people_id='.$leadactor_id;
$result=mysql_query($query,$db)or die (mysql_error($db));
$row= mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
//Riceve l'identificativo di un tipo di film e ne restituisce la descrizione
function get_movietype($type_id){
global $db;
$query='SELECT
movietype_label
FROM
movietype
WHERE
movietype_id='.$type_id;
$result= mysql_query($query,$db)or die(mysql_error($db));
$row= mysql_fetch_assoc($result);
extract($row);
return $movietype_label;
}
//Collegamento a Mysql
$db= mysql_connect('localhost','bismark','bismark')or die ('Connessione non riuscita. Inserisci i parametri corretti');
//Selezioniamo il Db corretto
mysql_select_db('moviesite',$db)or die(mysql_error($db));
//Recuperiamo le Informazioni
$query='SELECT
movie_name,movie_year,movie_director,movie_leadact or,movie_type
FROM
movie
ORDER BY
movie_name ASC,
movie_year DESC';
$result= mysql_query($query,$db)or die (mysql_error($db));
//Determiniamo quante righe ci sono nel risultato ottenuto
$num_movies= mysql_num_rows($result);
$table=<<<ENDHTML
<div style="text-align:center;">
<h2>ELENCO FILM</h2>
<table border="1" cellpadding="2" cellspacing="2"
style="width:70%;margin-left:auto;margin-right:auto;">
<tr>
<th>TITOLO FILM</th>
<th>ANNO USCITA</th>
<th>REGISTA FILM</th>
<th>ATTORE FILM</th>
<th>CATEGORIA FILM</th>
</tr>
ENDHTML;
//Scorriamo i risultati nel DB
while ($row= mysql_fetch_assoc($result)){
extract ($row);
$director=get_director($movie_director);
$leadactor= get_leadactor($movie_leadactor);
$movietype= get_movietype($movie_type);
$table .=<<<ENDHTML
<tr>
<td>$movie_name</td>
<td>$movie_year</td>
<td>$director</td>
<td>$leadactor</td>
<td>$movietype</td>
</tr>
ENDHTML;
}
$table.=<<<ENDHTML
</table>
$num_movies</p>
$righe</p>
</div>
ENDHTML;
echo $table;
?>
Sembra tutto ok ma quando lo eseguo mi dice:
Warning: mysql_query() expects parameter 2 to be resource, string given in C:\xampp\htdocs\Capitolo4\table2.php on line 15
Cosa può essere?