emontcol Posted September 9, 2020 Share Posted September 9, 2020 Hello, I hope all of you are safe with your families. Currently I am starting with PHP Coding and I am trying to do a simple query to MySQL DB using PHP but even when is able to bring the number of rows is not displaying the values in the DB. This is my code: <?php $servername = "localhost"; $database = "mydbtest"; $username = "root"; $password = "root"; // Create connection $conn = mysqli_connect($servername, $username, $password, $database); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } //echo "Connected successfully"; $myquery = "SELECT * FROM Country"; $result = $conn->query($myquery); $numf = $result->num_rows; echo "Number of rows " . $numf . "<br>"; if($numf >0){ while($row = $result->fetch_object()){ echo "Code" . $row->countrycode . "<br>"; echo "Country" . $row->countryname . "<br>"; } }else{ echo '0 results'; } mysql_free_result($myout); mysqli_close($conn); ?> What is failing? Thanks in advance for the assistance. Quote Link to comment https://forums.phpfreaks.com/topic/311454-query-not-bringing-data/ Share on other sites More sharing options...
mac_gyver Posted September 9, 2020 Share Posted September 9, 2020 44 minutes ago, emontcol said: I am starting with PHP Coding to get php to help you, find the php.ini that php is using and set error_reporting to E_ALL, display_errors to ON, and output_buffing to OFF. stop and start your web server to get any changes made to the php.ini to take effect. you should then be getting some php errors when you run your code that will help you find what the problem is. Quote Link to comment https://forums.phpfreaks.com/topic/311454-query-not-bringing-data/#findComment-1581257 Share on other sites More sharing options...
Barand Posted September 9, 2020 Share Posted September 9, 2020 (edited) To see if you have any mysql errors, put this line immediately before the line calling mysql_connect() mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); EDIT: and where is $myout defined? Edited September 9, 2020 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/311454-query-not-bringing-data/#findComment-1581258 Share on other sites More sharing options...
emontcol Posted September 19, 2020 Author Share Posted September 19, 2020 Thank you so much everyone, I was able to find out that the issue was with the fields when I was calling them from PHP ("They were in miniscule") Quote Link to comment https://forums.phpfreaks.com/topic/311454-query-not-bringing-data/#findComment-1581500 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.