Jump to content

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


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);

?>

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.