Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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);
    };
};
?>
share|improve this question
1  
Probably a missing ; at the end of line 46.... and indeed we see $stats = $_REQUEST['status'] without a ; at the end –  Mark Baker Jan 2 at 10:20
add comment

closed as off-topic by 웃웃웃웃웃, tereško, Sam Dufel, fvu, S.L. Barth Feb 28 at 16:03

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Sam Dufel, fvu, S.L. Barth
If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers

up vote 0 down vote accepted

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();
share|improve this answer
    
right, thank you. –  aldy505 Jan 3 at 13:29
add comment

Add a semicolon here:

$stats = $_REQUEST['status'];
share|improve this answer
add comment

Line 46 should end with a semicolon:

$stats = $_REQUEST['status'] <---

By the way, you should use prepared statements.

share|improve this answer
add comment

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.

share|improve this answer
    
i think it will be mysqli_query($con,$queryb) –  R R Jan 2 at 10:22
    
Yeah that is in the elseif part. See my answer. –  Shankar Damodaran Jan 2 at 10:22
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.