FW: Can you help?

From: Date: Tue, 29 Sep 2026 15:26:56 +0000
Subject: FW: Can you help?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-328869@lists.php.net to get a copy of this message
From: Chris Bas <chrisbas4u@outlook.com> Date: Tuesday, 29 September 2026 at 16:49 To: php-general@lists.php.net <php-general@lists.php.net> Subject: Can you help? Good day to you, I allow myself to disturb you. I try for long time to use PHP to truncate a table , please find below my script: <!DOCTYPE HTML> <html lang="en"> <head><meta charset="UTF-8"> <title>TRUNCATE with PHP</title> </head> <body> <?php $host = "localhost"; $user = “bill"; $mdp = “dogdog"; $base = "site_db"; $table = “fruit"; // Create connection $conn = new mysqli($host, $user, $mdp, $base); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully!"; function empty_table($dbc) { $q = "TRUNCATE TABLE fruit"; $r = mysqli_query($dbc, $q); if(mysqli_query($r)) // SUCCESS echo " table “.$fruit." made empty !"; else // FAILURE echo "table “.$fruit." was not empty."; } // WE EMPTY empty_table($table); ?> </body> </html> In Localhost I receive this result: Connected successfully! Fatal error: Uncaught TypeError: mysqli_query(): Argument #1 ($mysql) must be of type mysqli, string given in /Users/chris/Applications/Abyss Web Server/htdocs/empty.php:28 Stack trace: #0 /Users/chris/Applications/Abyss Web Server/htdocs/empty.php(28): mysqli_query() #1 /Users/chris/Applications/Abyss Web Server/htdocs/empty.php(37): empty_table() #2 {main} thrown in /Users/chris/Applications/Abyss Web Server/htdocs/empty.php on line 28 Line 28 being: $r = mysqli_query($dbc, $q); Well sorry to force myself but can you help! Many thanks Chris

« previous php.general (#328869) next »