FUNKAM35 Posted July 19, 2015 Share Posted July 19, 2015 $results = mysql_query("$select", $link_id); while ($query_data = mysql_fetch_row($results)) { $link_id = mysqli_connect("$db_host","$db_user","$db_password","$db_database"); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } $link_id = mysql_connect("$db_host","$db_user","$db_password"); if (mysql_select_db("$db_database", $link_id)); else { echo "connection failed."; } I am having to update MySQL to mysqli as my host is upgrading to PHP5.6 I have managed to convert and connect to the database converted to I cannot get the fetch results to work, can anyone help me convert the following code Many Thanks Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted July 19, 2015 Share Posted July 19, 2015 (edited) Code for fetching the results will be $results = $mysqli->query($link_id, $select); while ($query_data = $results->fetch_row())) { See respective manual pages on mysqli here http://php.net/mysqli http://php.net/mysqli.query http://php.net/mysqli-result.fetch-row Edited July 19, 2015 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
FUNKAM35 Posted July 19, 2015 Author Share Posted July 19, 2015 Thanks Ch0cu3r tried that and it says Fatal error: Call to a member function query() on a non-object Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted July 19, 2015 Share Posted July 19, 2015 (edited) Change $mysqli-> to be $link_id-> Edited July 19, 2015 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 19, 2015 Share Posted July 19, 2015 Change $mysqli-> to be $link_id-> Eh. I'd go the other way, change your $link_id to be $mysqli. That's more standard and you'd immediately know by looking at the code that $mysqli is probably a MYSQLI object. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.