-4

I got Error like this [Parse error: syntax error, unexpected 'connected' (T_STRING) in C:\xampp\htdocs\koneksi\update.php on line 5]

<?php

if($_SERVER['REQUEST_METHODE']=='POST){

include('connected.php');

$room=$_POST['NoRoom'];
$status=$_POST['RoomStatus'];

$Sql_Query="UPDATE cfg_init_room SET number='$room, status_code='$status';

if (mysqli_query($con,$SQl_Query));
{
    echo 'Status Updated';
}else{
    echo'Gagal Update Status';
}
}mysqli_close($con);
?>
Koen Hollander
  • 1,687
  • 6
  • 27
  • 42
  • 2
    (Not the problem but )Should it be `REQUEST_METHOD` (no E). – Nigel Ren Sep 16 '18 at 14:56
  • 2
    Please check your code for simple typo's. SO isn't a community where you just can submit code to repair it – Koen Hollander Sep 16 '18 at 14:58
  • Your line of SQL is missing a few quotes - `"UPDATE cfg_init_room SET number='$room', status_code='$status'";` – Nigel Ren Sep 16 '18 at 16:08
  • Your script is at risk of [SQL Injection Attack](//stackoverflow.com/questions/60174) Have a look at what happened to [Little Bobby Tables](http://bobby-tables.com/) Even [if you are escaping inputs, its not safe!](//stackoverflow.com/questions/5741187) Use [prepared parameterized statements](https://php.net/manual/en/mysqli.quickstart.prepared-statements.php). – John Conde Sep 16 '18 at 20:01
  • thanks for the answer, I got a mistake for simple typo's on my code – Muhammad Khalil Khaer Sep 19 '18 at 08:22

1 Answers1

1

On this line if($_SERVER['REQUEST_METHODE']=='POST){ there is a missing ' after POST.

Make that line if($_SERVER['REQUEST_METHODE']=='POST'){ and it should work.

On most IDEs you will see a shift in text color between strings and functions, just like here on SO.
That is a telling sign you forgot to close a string.

Edit: now that I look at your code more closely it seems you have another string problem.
At the end in the if else your strings are correct. They shouldn't.
So that means there is another problem with your strings, probably in $sql_query line.

Andreas
  • 23,610
  • 6
  • 30
  • 62
  • When the answer is "add one missing quote", there is no need to answer. Just leave a comment under the question and flag/vote to close as Off-topic: Typo. This page will be quickly scrubbed from the site (as will any upvote points you receive) because this page is completely useless to researchers.See: [Should one advise on off topic questions?](//meta.stackoverflow.com/q/276572/1768232). – John Conde Sep 16 '18 at 20:00