php - SQL query doesn't get values -


the sql query returns array in browser if there values in database. have tried query in phpmyadmin , works not in php document.

require_once('connect.php');  $query = "select `id` `questions` round='1' , year='2016'"; $sql = mysqli_query($dbconnect, $query);  $row = mysqli_fetch_array($sql, mysqli_assoc); 

almost same query works in different php documents. suggestions wrong? should query should return integers.

$query = "select `id` `questions` round='1' , year='2016'"; 

you're selecting id column. if wish echo more columns, need add them in query.

i.e.:

$query = "select `id`, `col2`, `col3` `questions` round=1 , year=2016"; 

then loop on results:

while ($row = mysqli_fetch_array($sql, mysqli_assoc)) {      echo $row['id'];      // echo "<br>";     // echo $row['col2'] . "<br>";      // echo $row['col3']; } 

check errors on query , assuming successful mysqli_ connection.

other reference:


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -