Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
create table ok (id int, val text);
insert into ok values (1, 'value');
<?php
$val = 'value';
////////////////
$sth = $pdo->prepare(
"SELECT 1
FROM `ok`
WHERE `val` = ?
LIMIT 1"
);
$sth->execute([$val]);
if ($sth->rowCount() > 0) {
printf("Value %s found in table `ok` column `val`", $val);
} else {
printf("Value %s not found in table `ok` column `val`", $val);
}