Jump to content

mysqli_fetch_array() expects parameter 1 to be mysqli_result....


TechGuy1

Recommended Posts

I am a php noob. I am trying to build a newsletter system and this script is suppose to give me a list of names, emails and id of the subscribers in the newsletter table. I am actually following along with a tutorial and I have the exact code they have but I am getting the following errors..

 

 

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, resource given in C:\xampp\htdocs\myprojects\newsletterremove.php on line 24

 

Warning: mysqli_close() expects parameter 1 to be mysqli, resource given in C:\xampp\htdocs\myprojects\newsletterremove.php on line 32

 

here is the code

 

<?php

//Connect to database

include('database.php');

 

if(isset($_POST['submit'])){

foreach($_POST['todelete'] as $delete_id){

$query = "DELETE FROM newsletter WHERE id = $delete_id";

mysql_query($query) or die('Error Querying Database');

}

echo 'Client(s) removed.<br />';

}

 

// Display the customer rows with checkboxes for deleting

  $query = "SELECT * FROM newsletter";

  $result = mysql_query($query);

  while ($row = mysqli_fetch_array($result)) {

    echo '<input type="checkbox" value="' . $row['id'] . '" name="todelete[]" />';

    echo $row['first_name'];

    echo ' ' . $row['last_name'];

    echo ' ' . $row['email'];

    echo '<br />';

  }

 

  mysqli_close($connection);

?>

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.