Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: m33rra - joulukuu 22, 2013, 05:28:46 IP

Otsikko: Simple error, but I am lost please help.
Kirjoitti: m33rra - joulukuu 22, 2013, 05:28:46 IP
This is for a custom SMF chat box I am working with. I need a simple script to delete all of the info from a table. The code is returning an error though:

Parse error: syntax error, unexpected '{' in /home/playtotd/public_html/play/deletelivechatmessages.php on line 21

<?php 
// Insert your database username here: 
$user="REMOVED"
// Insert your db password here: 
$password="REMOVED"
// Insert Database name: 
$database "REMOVED"

// The database table name: 
$table "ajax_chat_messages"
// you dont need to change this in most cases... 
$server ="localhost"

// code... 
$stmt "TRUNCHATE $table"
$mysqli = new mysqli($server$user$password$database); 
if (
$mysqli->connect_errno) { 
    echo 
"Failed to connect to MySQL: (" $mysqli->connect_errno ") " $mysqli->connect_error
    die(); 

if(
$r $mysqli->query($stmt) { 
        
$r->close(); 
} else die(
"An error happened: ".$r->error); 
?>
Otsikko: Re: Simple error, but I am lost please help.
Kirjoitti: Kindred - joulukuu 22, 2013, 06:55:37 IP
You are missing a closing parens in your second if statement
Otsikko: Re: Simple error, but I am lost please help.
Kirjoitti: margarett - joulukuu 23, 2013, 01:04:39 IP
And you should use $smcFunc instead of direct mysql function calls ;)