There is a script that works correctly on the local machine, but nothing happens when installing it on the server in the product.tpl file (cms OpenCart). The script takes the price from the table, taking into account the id of the product. Error code does not display any. Thanks for the help.
<?php $host = 'хост'; $db = 'имя бд'; $user = 'юзер нейм'; $pass = 'пароль'; $charset = 'utf8'; $dsn = "mysql:host=$host;dbname=$db;charset=$charset"; $opt = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ]; $pdo = new PDO($dsn, $user, $pass, $opt); $stmt = $pdo->prepare('SELECT price FROM oc_product WHERE product_id = ?'); $stmt->execute([$_GET['id']]); foreach ($stmt as $row) { echo 'price '.$row['price'] . "\n"; } ?>
var_dump($stmt->execute([$_GET['id']]));which will output if put instead of$stmt->execute([$_GET['id']]);? - Vismanvar_dump($stmt->fetchAll());and most likely you will see an empty array :) - Visman