Error from browser (or openserver): "mysqli_fetch_array () expects parameter 1 to be mysqli_result". It is necessary to just output from the database via php fields, do this:

$db = mysql_connect('localhost', 'root', '') or die('cant connect ot db: '. mysql_error()); $db_selected = mysql_select_db('Blog'); $result = mysql_query("SELECT * FROM 'Notes'"); do{ echo "ID - ".$myrow['id']."<br>"; echo "Note: ".$myrow['note']."<br>"; echo "date: ".$myrow['date']."<br>"; }while ($myrow = mysql_fetch_array($result, MYSQL_BOTH)); 

I read php.net and google, went through various variations of mysql_fetch and its parameters, but all is in vain, there is a warning on the site that the extension is outdated and from version 7 php is not supported, but I have an error about the parameter;

  • you work with mysqli and $ result you have mysql - StereoFlo
  • I went through the options, returned everything to mysql, the error is the same, it expects 1 parameter to be a resource. The resource should be the idea of ​​$ result, if you believe the documentation, but something I am doing wrong ( - Vladislav Dementyev
  • A resource is a data type if you carefully read the documentation. - Nikolaj Sarry
  • I understood it from her, only how this knowledge will help? typing is dynamic. - Vladislav Dementiev

1 answer 1

Try:

 $conn = mysqli_connect('localhost','user','password','database'); $query = 'select * from tableName'; $result = mysqli_query($conn, $query); $data = mysqli_fetch_all($result,MYSQLI_ASSOC); foreach ($data as $item) { echo "ID - ".$item['id']."<br>"; echo "Note: ".$item['note']."<br>"; echo "date: ".$item['date']."<br>"; } 
  • Everything works, thank you very much. Apparently mysql really lost relevance and need to use mysqli. - Vladislav Dementiev