Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting Mysql to Mysqli
    primarykey
    data
    text
    <p>I was told to stop using MySQL and now learning MySQLi. However I ran into a problem using fetch array and don't know what I did wrong.</p> <pre><code>//Connect to db include "mysqli_connect.php"; // Construct our join query $sql = "SELECT userID, username, lastlogin FROM users"; //Crate results $result = mysqli_query($link, $sql); // Print out the contents of each row into a table $row = mysqli_fetch_array($result, MYSQLI_BOTH); // Free result set mysqli_free_result($result); // Close connection mysqli_close($link); </code></pre> <p><hr> Messages I see:</p> <ul> <li>[Connection Successful] Host info: db413417616.db.1and1.com via TCP/IP</li> <li>Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in /homepages/9/d413002686/htdocs/maintenance/testsession.php on line 9</li> <li>Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /homepages/9/d413002686/htdocs/maintenance/testsession.php on line 12</li> <li>Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, null given in /homepages/9/d413002686/htdocs/maintenance/testsession.php on line 15</li> <li>Warning: mysqli_close() [function.mysqli-close]: Couldn't fetch mysqli in /homepages/9/d413002686/htdocs/maintenance/testsession.php on line 18 ()</li> </ul> <p>I used this to for mysqli_connect.php: <a href="http://www.php.net/manual/en/mysqli.construct.php" rel="nofollow">http://www.php.net/manual/en/mysqli.construct.php</a></p> <pre><code>&lt;?php // $link (host, username, password, database) $link = mysqli_connect('host', 'username', 'password', 'database'); //If connection is successful, otherwise show error message. if (!$link) { die('[Connect Fail] Error: (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } // Echo success message echo '[Connection Successful] Host info: ' . mysqli_get_host_info($link) . "\n"; // Close the link mysqli_close($link); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload