Please, how do i fix this please. I have initially being using mysql with which i have issues. Now i have started learning mysqli. I don't know all the details now but i need to make this script work and secure. Currently i have this:
Parse error: syntax error, unexpected '$_POST' (T_VARIABLE) in C:\xampp\htdocs\yomi\admin\update.php on line 27
Query:
CREATE TABLE IF NOT EXISTS `news` (
`id` int(10) NOT NULL,
`title` varchar(225) NOT NULL,
`brief` varchar(500) NOT NULL,
`contents` varchar(2000) NOT NULL,
`author` varchar(2000) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
PHP:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "my_db";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// prepare and bind
$stmt = $mysqli->prepare("UPDATE news SET title = ?,
brief = ?,
contents = ?,
author = ?
WHERE id = 1");
// set parameters and execute
$stmt->bind_param("ssssi", $_POST['title'],
$_POST['brief'],
$_POST['contents'],
$_POST['author'],
$_POST['id']);
$stmt->execute();
echo "New records updated successfully";
$conn->close();
?>