Have been trying to connect to the database using procedural php but i get error array to string conversion -


<?php function connect() { $conn = new mysqli('localhost','root','','test' ) or     die ('there problem connecting        db.'); return $conn; } function select_db($conn){    $stmt = $conn->prepare('select id,username,password users') or        die('problem query.');    $stmt->execute();    $stmt->bind_result($id,$username,$password);    $rows = array();    while ( $row = $stmt->fetch() )         {      $item = array(        "id"=> $id,         "username"=>$username,         "password" =>$password        );        $rows[] = $item;    }    return $rows; } 

have been trying connect database using procedural php error array string conversion. below code , respective errors. please trace error in code.

notice: array string conversion in c:\wamp\www\mysql_project\index.php.php on line 15 notice: array string conversion in c:\wamp\www\mysql_project\index.php.php on line 16 notice: array string conversion in c:\wamp\www\mysql_project\index.php.php on line 17 

since you're doing select try doing regular query(). there's no need on complicate using prepared statements

$res = $conn->query('select id,username,password users'); $rows = array(); while( $row = $res->fetch_assoc() ) $rows[] = $row; 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

jquery - Keeping Kendo Datepicker in min/max range -