Jump to content

Recommended Posts

Fatal error: Uncaught Error: Object of class mysqli could not be converted to string in C:\xampp\htdocs\php\delete_entry.php:97 Stack trace: #0 {main} thrown in C:\xampp\htdocs\ogani\delete_entry.php on line 97

<?php
    $dbc = mysqli_connect('localhost', 'root', '');
    mysqli_select_db($dbc,'product');
    
    if(isset($_GET['pname'])){
        $query = "SELECT * FROM myproduct WHERE ProductName='{$_GET['pname']}'";
        
        if($result = mysqli_query($dbc,$query)){
            $row = mysqli_fetch_assoc($result);
            
            print '<form action ="delete_entry.php" method = "post">
            <p>Are you sure you want to delete this entry?</p>
            <p><h3>' .$row["ProductName"]. ' </h3> </br> 
            <input type ="hidden" name="pname" value="' .$_GET['pname'] . '"/>
            <input type ="submit" name="submit" value ="Delete this entry!"/></p>
            </form>';
        }else{
            print '<p style="color:red;">Could not retrieve the blog entry because :<br/> '.mysqli_error($dbc) .'';
        }
    }
        
    else if(isset($_POST['pname'])){
        $query = "DELETE FROM entries WHERE ProductName= '{$_POST['pname']}'";
        $result  = mysqli_query($dbc,$query);
        if(mysqli_affected_rows($dbc) == 1){
            print "<p> The blog entry has been delete.</p>";
        }else{
            print "<p style='color:red;'>Could not delete the blog entry because :<br/>' .mysqli_error($dbc)";
        }
    
    }
    mysqli_close($dbc);
    ?>

Link to comment
https://forums.phpfreaks.com/topic/311097-help-me-with-this-error-on-php-ty/
Share on other sites

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.