I get this error: PHP Parse error: syntax error, unexpected T_VARIABLE on line 47
The 47th line is:
$queryb = "UPDATE `situation` SET `status`='" . $stats . "', `time`='" . $time . "', `name`='" . $name . "', `notes`='" . $notes . "'";
I just don't get it. Maybe script error or syntax error?
<?php
function lanjut($c) {
$submitdata = "success";
if ($c = "message") {
$time = $_REQUEST['time'];
$name = $_REQUEST['name'];
$body = $_REQUEST['body'];
$con = mysqli_connect("this,is,already,true");
$querya = "INSERT INTO `message` (`name`, `time`, `body`) VALUES ('" . $name . "', '" . $time . "', '" . $body . "')";
mysqli_query($con,$query);
mysqli_close($con);
} elseif ($c = "setting") {
$time = $_REQUEST['time'];
$name = $_REQUEST['name'];
$notes = $_REQUEST['notes'];
$con = mysqli_connect("this,is,already,true");
$stats = $_REQUEST['status']
$queryb = "UPDATE `situation` SET `status`='" . $stats . "', `time`='" . $time . "', `name`='" . $name . "', `notes`='" . $notes . "'";
mysqli_query($con,$query);
mysqli_close($con);
};
};
?>
Code without any syntax error will be
<?php
function lanjut($c)
{
$submitdata = "success";
if($c = "message") {
$time = $_REQUEST['time'];
$name = $_REQUEST['name'];
$body = $_REQUEST['body'];
$con = mysqli_connect("this,is,already,true");
$querya = "INSERT INTO `message` (`name`, `time`, `body`) VALUES ('" . $name . "', '" . $time . "', '" . $body . "')";
mysqli_query($con, $querya);
mysqli_close($con);
} elseif($c = "setting") {
$time = $_REQUEST['time'];
$name = $_REQUEST['name'];
$notes = $_REQUEST['notes'];
$con = mysqli_connect("this,is,already,true");
$stats = $_REQUEST['status'];
$queryb = "UPDATE `situation` SET `status`='" . $stats . "', `time`='" . $time . "', `name`='" . $name . "', `notes`='" . $notes . "'";
mysqli_query($con, $queryb);
mysqli_close($con);
}
}
?>
A better way is to user prepared statements like
$querya = $con->prepare("INSERT INTO `message` (`name`, `time`, `body`) VALUES (? , ?, ?");
$querya->bind_param('sss', $name, $time, $body);
$querya->execute();
Change this to mysqli_query($con,$querya);
i.e. you don't have a $query
variable. in the first if
statement , Similarly do this mysqli_query($con,$queryb);
on your elseif
statement.
and add a semicolon here $stats = $_REQUEST['status']; //<------
as MillaresRoo
and moonwave99
mentioned.
Add a semicolon here:
$stats = $_REQUEST['status'];
Line 46 should end with a semicolon:
$stats = $_REQUEST['status'] <---
By the way, you should use prepared statements.