0

pls am trying to select data from user table and i keep getting this -> Parse error: syntax error, unexpected 'array' (T_ARRAY) in C:\xampp\htdocs\login\selt.php on line 10

$conn = mysqli_connect("localhost", "root", "", "logintest");

 if (!$conn) {
die("connection aborted: ".mysqli_connect_error()); }
$run = mysql_query("Select * from user") ;
while($row=mysql_fetch array($run))

..Thanks

Specter
  • 3
  • 3
  • Can you identify which of those is line 10? Also, you appear to be using the old mysql_XXX functions where I suspect you intended to use the mysqli_XXX functions... – A C Feb 05 '17 at 06:03
  • The fetch array line is line 10..Thanks – Specter Feb 05 '17 at 08:27
  • It's just a typo: `mysql_fetch array` instead of `mysql_fetch_array`. And even that would be yet another typo: `mysql_` instead of `mysqli_` (just like you have `mysql_query` instead of `mysqli_query`). – Álvaro González Feb 05 '17 at 14:39

2 Answers2

0

If you have already mysqli_connect before, I think you have to use mysqli_* functions.

And You have to use in this way.

$run = mysqli_query($conn,"Select * from user");

$row = mysqli_fetch_array($run, MYSQLI_BOTH);
...
mysqli_free_result($run);
mysqli_close($conn);

Reference this page: http://php.net/manual/en/mysqli-result.fetch-array.php

Star_Man
  • 1,091
  • 1
  • 13
  • 30
0

The error is coming from the space in the middle of mysql_fetch array (should be mysql_fetch_array) but as I mentioned up there (and so did @Star_Man) you should also watch out for mixing mysqli and mysql functions.

A C
  • 705
  • 6
  • 9