-1

Im having a problem I did a research and common problem is lack of semi colon but I am sure that there's nothing wrong in my code please check this out.

    <?php
require 'connection.php';
 
$query = "select id from `account_info`";
 
$res = mysqli_query($connect,$query);
 
$result = array();
 
while($row = mysqli_fetch_array($res)){
array_push($result,
array('id'=>$row[0]
));
}
 
echo json_encode(array("result"=>$result));
 
mysqli_close($connect);
 
?>

connection.php

<?php 

define('hostname','mysql.hostinger.ph');
define('user','********_mftis');
define('password','********');
define('databaseName','u366906409_mftis');
$connect = mysqli_connect(hostname,user,password,databaseName);
?>
Jaypee Tan
  • 101
  • 1
  • 10
  • Wrap off quotes from `table and column` name instead use backtick – Saty Jul 12 '16 at 11:10
  • did you try this , remove Double quote from account_info in Query – Dharmendra Jul 12 '16 at 11:11
  • @Saty is correct and the error there will be revealed as soon as this is fixed, however the quoted error is most likely coming from a syntax error in `connection.php` . Can you share that code as well? – apokryfos Jul 12 '16 at 11:13
  • I tried removing the double quotes.. still not working – Jaypee Tan Jul 12 '16 at 11:13
  • 1
    Quick note: you select `*` but only gets what seems to be the id column. It would be (arguably) better to just select the id then... – FirstOne Jul 12 '16 at 11:14
  • 1
    Your issue resides in code that you haven't posted or that got mangled when copy'n'pasting (wrong file/version, Unicode chars, etc). – mario Jul 12 '16 at 11:14
  • I suggest you have a file corruption of some sort. Recode your `connection.php` or just copy/paste it into a new file and then rename it. If that does not work, do the same to the main code – RiggsFolly Jul 12 '16 at 11:23

1 Answers1

0

write your query as

$query = "select * from 'account_info'";
A.L
  • 10,259
  • 10
  • 67
  • 98
Harsh Srivastava
  • 376
  • 2
  • 10