Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
$sql_update = "UPDATE `numbers_book` SET `name`='$num' WHERE `id`= ".$id;
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
$charset = 'utf8'; $options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]; try{ $pdo = new PDO("mysql:localhost;dbname=copyhomework;charset=$charset", 'root', '', $options); }catch(PDOException $e){ exit('Не удалось подключиться к базе данных!'); } $from = 427; $to = 436; for ($i = $from; $i <= $to; $i++) { replacement($i); } function replacement($topic_id) { echo $topic_id.'<br>'; $sql = 'SELECT * FROM `numbers_book` WHERE `topic_id` = :topic_id'; $stmt = $pdo->prepare($sql); $stmt->execute( [':topic_id' => $topic_id] ); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo $row['num']; } }
function replacement($pdo, $topic_id)
replacement($pdo, $i);
$stmt->execute( [':topic_id' => $topic_id] );
$sql = 'SELECT * FROM `numbers_book ` WHERE `topic_id` = :topic_id';
$sql = 'SELECT * FROM copyhomework.numbers_book WHERE `topic_id` = :topic_id';