Hi,
Folks,
Why some php code like this with the arrow:
->
New Version
[code]
$mysqli = new mysqli(HOST, USERNAME, PASSWORD, DATABASE);
$stmt = $mysqli -> prepare(‘UPDATE users SET name = ? WHERE id = ? LIMIT 1’);
$name = ‘Joe’;
$id = 1;
if (
$stmt &&
$stmt -> bind_param(‘si’, $name, $id) &&
$stmt -> execute() &&
$stmt -> affected_rows === 1
) {
echo ‘Updated’;
} else {
echo ‘Not updated’;
}
While other codes are with the brackets:
Old Version
[code]
mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
$conn = mysqli_connect(“localhost”,”root”,””,”buzz”); //mysqli_connect(“server”,”user”,”password”,”db”);
$input_1 = ‘fat’; //keyword.
$stmt = mysqli_prepare($conn,”SELECT COUNT(id) from links WHERE keyword = ?”);
mysqli_stmt_bind_param($stmt,”s”,$input_1);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt,$output_1);
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
mysqli_close($conn);
printf(‘Found Result: %s’,$output_1);
This is why I decided to move over to Python.
Php is one lang but yet so many different syntaxes.