Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php function para_query($mysqli, $query, $args = []) { $query = str_replace("%s","'%s'",$query); foreach ($args as $key => $val) { $args[$key] = mysqli_real_escape_string($mysqli, $val); } $query = vsprintf($query, $args); $result = mysqli_query($mysqli, $query); return $result; } $query = "SELECT * FROM sakila.film WHERE title like %s LIMIT %d"; $search = ''; $limit = 1; $result = para_query($mysqli, $query, ["%$search%", $limit]); echo json_encode($result->fetch_assoc());
Copy Clear