0

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.
3
Contributors
6
Replies
29
Views
3 Years
Discussion Span
Last Post by Kniggles_2
1

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'");
0

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

0

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;
?>

Edited by Kniggles_2: to add the new php

1

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'");

Edited by DJBirdi

0

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 .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.