Huongle08 Posted August 2, 2019 Share Posted August 2, 2019 Fairly new to PHP and have the following code which should simply output into 3 columns - I have checked the query which does work - so I dont understand why I get this error mysql_fetch_array() expects parameter 1 to be resource, // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = “SELECT * FROM duration_matched WHERE groupm = '”.$coincidence ."’"; $result = $conn->query($sql); // set up loop counter $col_count = 0; // start table and first tr echo ‘ ’; while ($row=mysql_fetch_array($result)) { // if you have output 3 cols then end tr and start a new one if ($col_count == 3) { echo ‘ ’; // and reset the col count $col_count = 0; } // always output the td echo ‘ ’; // and count the column $col_count++; } // then close off the last row and the table echo ‘ ’ . $row[‘image’] . ‘ ’; $conn->close(); Quote Link to comment https://forums.phpfreaks.com/topic/309056-get-this-error-code/ Share on other sites More sharing options...
chhorn Posted August 2, 2019 Share Posted August 2, 2019 and what type is parameter 1? Check with var_dump(). Quote Link to comment https://forums.phpfreaks.com/topic/309056-get-this-error-code/#findComment-1568834 Share on other sites More sharing options...
Barand Posted August 2, 2019 Share Posted August 2, 2019 Also note that you created (correctly) a mysqli connection but you have switched to a mysql_ library function that is now obsolete Quote Link to comment https://forums.phpfreaks.com/topic/309056-get-this-error-code/#findComment-1568835 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.