Jump to content

how to fix extract warning


vinson89

Recommended Posts

Here is the php code:

 

<?php
//include database connection
include 'dbconnect.php';
 
// if the form was submitted/posted, update the item
if($_POST){
 
    //write query
    $sql = "UPDATE 
                item_information 
            SET
                itemtitle = ?, 
                itemdescription = ?,
                date = ?,
            WHERE 
                itemid= ?";
     
    $stmt = $mysqli->prepare($sql);
     
    // you can bind params this way,
    // if you want to see the other way, see our add.php
    $stmt->bind_param(
        'sssi', 
        $_POST['itemtitle'], 
        $_POST['itemdescription'],
        $_POST['date'],
        $_POST['itemid']
    );
     
    // execute the update statement
    if($stmt->execute()){
        echo "Item was updated.";
         
        // close the prepared statement
        $stmt->close();
    }else{
        die("Unable to update.");
    }
}
 
$sql = "SELECT 
            itemid, itemtitle, itemdescription, date
        FROM 
            item_information
        WHERE 
            id = \"" . $mysqli->real_escape_string($_GET['itemid']) . "\"
        LIMIT 
            0,1";
 
// execute the sql query
$result = $mysqli->query( $sql );
 
//get the result
$row = $result->fetch_assoc();
 
extract($row);
 
//disconnect from database
$result->free();
$mysqli->close();
?>

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.