mysqli - Trying to understand 'mysqli_fetch_array' I fail to run an example -
The following code is the easiest, I can understand how to work with 'mysqli_fetch_array'.
& lt ;? Php is required ('mysqli_connect.php'); $ Sql = "SELECT 'fname', 'email', 'pass' FROM 'list'"; $ Line = mysqli_fetch_array ($ result, MYSQLI_NUM); While ($ line! == faucet) {echo $ row [0] ' '$ Line [1]' '. $ Line [2]; Echo & lt; Br / & gt; '; } Mysqli_close ($ dbcon); ? & Gt;
This code produces the following error message:
Warning: mysqli_fetch_array () parameter 1 is expected to be mysqli_result, given in Boolean C : \ Xampp \ htdocs \ Test \ mysqli_connect_test.php on line 5
Can someone advise me how this code works? What does "MYSQLI_NUM" mean? Thank you
Observe that your code is very wrong:
Requires 'mysqli_connect.php'; $ Sql = "select fname`,` email`, `pass` `` to list ''; // # 1 $ result = $ dbcon-> Query ($ sql); // # 2 while ($ line = $ result-> fetch_array (MYSQLI_NUM)) // # 3 {resonant "{$ row [0]}. {$ Row [1]}. {$ Row [2]} & Lt; br & gt; "; } $ Dbcon- & gt; Close ();
Note # 1: ''
Invalid cover for mysql object names I ''
is used to wrap strings only should be done. Also, you do not need to wrap them until the name of the object is reserved.
Note # 2: You must execute the query to generate $ result
. Note # 3: You should run fetch_array ()
each loop and can not change the value of $ row
otherwise just once And this is an infinite loop.
Consider using mysqli
class methods instead of stand-alone tasks. The code cleaner looks more understandable. Functions like mysqli_query ()
are only for backward compatibility with call_user_func ()
and call_user_func_array ()
.
Comments
Post a Comment