$host = '127.0.0.1';
$db = 'test';
$user = 'root';
$pass = '';
$charset = 'utf8mb4';
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
try {
$mysqli = mysqli_connect($host, $user, $pass, $db);
mysqli_set_charset($mysqli, $charset);
} catch (\mysqli_sql_exception $e) {
throw new \mysqli_sql_exception($e->getMessage(), $e->getCode());
}
unset($host, $db, $user, $pass, $charset);
$result = mysqli_query($mysqli, "SELECT * FROM admin WHERE uid='1'");
$row = mysqli_fetch_assoc($result);
$guid_agent = $row_admin['guid_agent'];
$agent = $row_admin['agent'];
$sql = "SELECT * FROM users WHERE id=?"; // знак вопроса вместо переменной
$stmt = $conn->query($sql);
$stmt->bind_param("s", $id); // переменная идет сюда
$Stmt->execute();
$result = $stmt->get_result(); // получаем result
$user = $result->fetch_assoc(); // получаем массив
$host = 'booktst.beget.tech';
$db = '';
$user = '';
$pass = '';
$charset = 'utf8mb4';
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
try {
$mysqli = mysqli_connect($host, $user, $pass, $db);
mysqli_set_charset($mysqli, $charset);
} catch (\mysqli_sql_exception $e) {
throw new \mysqli_sql_exception($e->getMessage(), $e->getCode());
}
unset($host, $db, $user, $pass, $charset); // we don't need them anymore
ini_set('display_errors', 0);
ini_set('log_errors', 1);
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
{% block stylesheets %}
<link href="/css/main.css" rel="stylesheet">
{% endblock %}
<title>{% block title %}Twig Example{% endblock %}</title>
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
{% extends "main.twig.html" %}
{% block content %}
<h1> index page </h1>
<li><a href=/page1.php>Page 1</a>
<li><a href=/page2.php>Page 2</a>
{% endblock %}
{% extends "main.twig.html" %}
{% block stylesheets %}
{{ parent() }}
<link href="/css/page1.css" rel="stylesheet">
{% endblock %}
{% block title %}Page 1{% endblock %}
{% block content %}
<h1> page 1</h1>
<li><a href=index.php>index</a>
{% endblock %}
Подскажите, пожалуйста, в чём проблема?
if (isset($_POST['search'])) {
require 'mysqli.php';
$stmt= $mysqli->prepare("SELECT * FROM `persons` WHERE firstname=?");
$stmt->bind_param("s", $_POST['fname']);
$stmt->execute();
$result = $stmt->get_result();
while($r = mysqli_fetch_assoc($result)){ ?>
<tr>
<td><?= $r['id']; ?></td>
<td><?= $r['firstname']; ?></td>
<td><?= $r['lastname']; ?></td>
<td><?= $r['age']; ?></td>
<td><?= $r['gender']; ?></td>
<td><?= $r['city']; ?></td>
</tr>
<?php
}
} ?>
function addTask($db, $name, $task){
$sql = "INSERT INTO tasks (name, task) VALUES (?,?)";
$statement = $db->prepare($sql);
$statement->execute([$name, $task]);
}
<?php
if (empty($_POST['email']) || empty($_POST['pass'])) {
die ("Enter credentials");
}
require 'pdo.php';
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
$stmt->execute([$_POST['email']]);
$user = $stmt->fetch();
if ($user && password_verify($_POST['pass'], $user['pass']))
{
session_start();
$_SESSION['user'] = $user;
header("Location: /dashboard.php");
exit;
} else {
die ("Wrong credentials");
}