![]() |
|
[PHP] mysql_fetch_array to mysqli - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183) +---- Thread: [PHP] mysql_fetch_array to mysqli (/showthread.php?tid=5729794) |
mysql_fetch_array to mysqli - deadsh0t - Oct 3, 2017 Im trying to update my code to mysqli to make it php 7 ready so i updated the db connection and now it works fine however executing and getting result from a query doesnt give any response anyone knows what im doing wrong ? here the part PHP Code * - Lrrr - Oct 3, 2017 (Oct 3, 2017 06:48 AM)deadsh0t Wrote: Im trying to update my code to mysqli to make it php 7 ready so i updated the db connection and now it works fine however executing and getting result from a query doesnt give any response anyone knows what im doing wrong ? if you run the following code: PHP Code And you get a NULL response, you should run the same query locally on the DB to insure it actually returns data. * - deadsh0t - Oct 3, 2017 (Oct 3, 2017 09:24 AM)Lrrr Wrote: if you run the following code: If i change it back to mysql instead of mysqli it works fine the query returns data it inly turns to no result when trying to convert it to mysqli * - remix.cpp - Oct 3, 2017 (Oct 3, 2017 09:35 AM)deadsh0t Wrote: If i change it back to mysql instead of mysqli it works fine the query returns data it inly turns to no result when trying to convert it to mysqli because u need to pass a mysqli instance to mysqli_query example: PHP Code * - Squito - Oct 3, 2017 Also either use mysqli_fetch_assoc instead of mysqli_fetch_array or use the second parameter of mysqli_fetch_array. * - deadsh0t - Oct 3, 2017 (Oct 3, 2017 10:43 AM)remix.cpp Wrote: because u need to pass a mysqli instance to mysqli_query Yeah this worked thanks however i include a dbconfig.php at the beginning at the file can you explain why i needed t open a new connection instead of using the connection already present ? Or is this specific for mysqli ? * - Squito - Oct 3, 2017 (Oct 3, 2017 01:02 PM)deadsh0t Wrote: Yeah this worked thanks however i include a dbconfig.php at the beginning at the file can you explain why i needed t open a new connection instead of using the connection already present ? http://php.net/manual/en/mysqli.query.php Quote:link * - deadsh0t - Oct 3, 2017 (Oct 3, 2017 01:12 PM)Squito Wrote: http://php.net/manual/en/mysqli.query.php Thanks! this explained it pretty well * - mobi35 - Oct 7, 2017 (Oct 3, 2017 06:48 AM)deadsh0t Wrote: Im trying to update my code to mysqli to make it php 7 ready so i updated the db connection and now it works fine however executing and getting result from a query doesnt give any response anyone knows what im doing wrong ? PHP Code I think you need to include the connection on the query * - Nyctophiliac - Oct 13, 2017 (Oct 3, 2017 06:48 AM)deadsh0t Wrote: Im trying to update my code to mysqli to make it php 7 ready so i updated the db connection and now it works fine however executing and getting result from a query doesnt give any response anyone knows what im doing wrong ? mysqli_query requires 2 parameters 1.) Mysqli Database link 2.) Query You're giving it only the query. |