Hi All ,
am geting this error

Parse error: syntax error, unexpected ';' in /home/a2856241/public_html/plus1.php on line 10

whith this code,

<?php

$con=mysqli_connect("host1","djslim","opensaysme","missionbase1");
// Check connection

if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

mysqli_query($con,"UPDATE table1 SET score=score+1 WHERE id=['$id'])";

mysqli_close($con);

header('Location: ./LaunchControl.php');

exit;
?>

I have changed it to read "WHERE id='1'" and this works, 
any ideas ?
thanks.

Hi, On line 10, " should be before ). Also,why are you using ['$id']? Just '$id' would be sufficient.
So, finally, change line 10 as shown below:

mysqli_query($con,"UPDATE table1 SET score=score+1 WHERE id='$id'");

Thanks, not getting the error anymore, still not updating the score though.

can anyone see if the error is in the html please ?

<form name="Form1" method="post" action="/plus1.php" enctype="multipart/form-data" id="Form1">
<input type="number" id="id" style="position:absolute;left:8px;top:12px;width:119px;height:42px;line-height:42px;z-index:11;" name="id" value="">
<input type="submit" id="Button1" name="" value="Submit" style="position:absolute;left:137px;top:9px;width:96px;height:25px;z-index:12;">
<input type="text" id="username" style="position:absolute;left:139px;top:48px;width:123px;height:41px;line-height:41px;z-index:13;" name="username" value="">
</form>

And this is the new php

<?php
$con=mysqli_connect("host1","djslim","opensaysme","missionbase1");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"UPDATE table1 SET score=score+1 WHERE id='$id'");
mysqli_close($con);
header('Location: ./LaunchControl.php');
exit;
?>

score is not being set with a valid input. You should create a variable that increments the score first, then use that variable in your query:

$new_score = $old_score + 1

mysqli_query($con,"UPDATE table1 SET score='$new_score' WHERE id='$id'");

hi Thanks for helpping ,

your code returnes

Parse error: syntax error, unexpected T_STRING in /home/a3454341/public_html/plus1.php on line 10

it works where id='1' so to my tinking the intger of the id string is not being passed or recived as when the button is clicked it resolves to the right page and not the error page .

it needed

 $id = $_POST['id'];

before line 10

Thanks everyone :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.