Problemi con mysql_fetch_array

3 contenuti / 0 new
Ultimo contenuto
Problemi con mysql_fetch_array

Per estrarre i dati da una tabella, in cui sono stati inseriti da un webform, ho provato a creare una pagina che contenga un codice php che vi riporto sotto.

All'esecuzione, ottengo il messaggio

"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in eval() (linea 21 di C:\\drupal-7.12\mobilita ppaa\modules\php\php.module(80) : eval()'d code)."

Qualcuo sa dirmi cosa sbaglio?

Grazie

Angelo

-----

<?php
$con
= mysql_connect("localhost","Utente","Password");
if (!
$con)
  {
  die(
'Could not connect: ' . mysql_error());
  }
mysql_select_db("mobilita_ppaa", $con);
$result = mysql_query("SELECT * FROM webform_submitted_data WHERE Nid=4");
echo
"<table border='1'>
<tr>
<th>Nome</th>
<th>Cognome</th>
<th>Città</th>
<th>Indirizzo</th>
<th>CAP</th>
</tr>"
;
while(
$row = mysql_fetch_array($result))
  {
  echo
"<tr>";
  echo
"<td>" . $row['Nome'] . "</td>";
  echo
"<td>" . $row['Cognome'] . "</td>";
  echo
"<td>" . $row['Città'] . "</td>";
  echo
"<td>" . $row['Indirizzo'] . "</td>";
  echo
"<td>" . $row['CAP'] . "</td>";
  echo
"</tr>";
  }
echo
"</table>";
mysql_close($con);
?>

Problema risolto: l'utente definito in Drupal ha accesso a localhost ma non automaticamente ai vari DB, quindi va creato all'interno del MySql DB specifico.
Il messaggio di errore su mysql_fetch_array derivava quindi dal fatto che la SELECT in realtà non veniva eseguita.

Ma perché non usare le funzioni della DB API di Drupal?