Below is error log :-
PHP Parse error: syntax error, unexpected 'deleteBike' (T_STRING), expecting '(' in /var/www/html/page/db.php on line 126, referer: http://localhost/page/adminpage/intro.html [Wed Jan 17 20:29:17.889348 2018]
Below is my db.php:
//add bike
static function addBike($mysqli, $bicycle_type,$station_id){
if ($stmt = $mysqli->prepare('INSERT INTO bicycle (bicycle_type, station_id) VALUES (?, ?)')){
$stmt->bind_param('si', $bicycle_type, $station_id);
if ($stmt->execute()){
return true;
} else {
return false;
}
}
//delete bike
static function deleteBike($mysqli,$bicycle_id){
if($stmt = $mysqli->prepare('DELETE FROM bicycle WHERE bicycle_id = ?')){
$stmt->bind_param('i',$bicycle_id);
if($stmt->execute()){
return true;
}else{
return false;
}
}
}
Below is from updateBike.php:
// if the method is POST
if ($_POST){
$bicycle_type = $_POST['bicycle_type'];
$station_id = $_POST['station_id'];
if (Db::addBike($mysqli, $bicycle_type, $station_id)){
echo 'success!';
}
}
Below is from intro.html:
<form method="post" action="updateBike.php"
<input type="text" name="bicycle_type">
<input type="number" name="station_id">
<input type="submit" value="Submit">
</div>
</form>
Based on the error log, deletebike()
has some error but I cannot even call addbike()
eventhough deleteBike()
is the one got error stated above.
I have been trying this for 2 hours, I know that I miss some simple mistake but I cannot figure it out. Your help will be much appreciated. :)