mysql_fetch_array() expects parameter 1 to be resource
Bonjour, j'ai lu des tas de forums mais impossible de résoudre mon erreur. Voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
function generateTypeJson($connect){
$req_str = "SELECT * FROM Type";
$req = getRequest($connect,$req_str);
if (!$req) {
//echo "Probleme req !! ";
//return false;
}
$num_row = mysql_num_rows($req);
$txt = "{\"identifier\":\"id\",\"label\":\"type\",\"items\":[";
while($row = mysql_fetch_array($req)) {
$txt .= "{\"id\":".$row['id_type'].",";
$txt .= "\"nom\":".$row['nom_type']."}";
if($i!=$num_rows)
$txt .=",";
}
$txt .= "]}";
$fp = fopen ("json_type.php", "w");
fputs($fp, $txt);
fclose($fp);
}
function getRequest($connect,$requete) {
if (mysqli_autocommit($connect, FALSE)) {
$req=mysqli_query($connect,$requete);
//if($req == false) {
//return false;
//}
mysqli_commit($connect);
return $req;
} else {
return false;
}
} |
probleme avec la fonction mysql_num_rows()
merci de votre aide.