Ultimatezai Posted July 15, 2020 Share Posted July 15, 2020 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); ?> Quote Link to comment Share on other sites More sharing options...
Barand Posted July 15, 2020 Share Posted July 15, 2020 Which of those 34 lines is line 97? Quote Link to comment Share on other sites More sharing options...
Ultimatezai Posted July 15, 2020 Author Share Posted July 15, 2020 print "<p style='color:red;'>Could not delete the blog entry because :<br/>' .mysqli_error($dbc)"; Quote Link to comment Share on other sites More sharing options...
benanamen Posted July 15, 2020 Share Posted July 15, 2020 print "<p style='color:red;'>Could not delete the blog entry because :<br/>" .mysqli_error($dbc); 1 Quote Link to comment Share on other sites More sharing options...
Ultimatezai Posted July 15, 2020 Author Share Posted July 15, 2020 same error Quote Link to comment Share on other sites More sharing options...
requinix Posted July 15, 2020 Share Posted July 15, 2020 1 hour ago, Ultimatezai said: same error No, benanamen's code will not result in the same error. Try again. 1 Quote Link to comment Share on other sites More sharing options...
Ultimatezai Posted July 16, 2020 Author Share Posted July 16, 2020 Thank you, it works now Quote Link to comment 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.