Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
since you defined $db above and not $pdo you should use that for prepare, also improved readability.
Source Link

create the pdo connection like

$db = new PDO('mysql:host=localhost;dbname=testdb;charset=UTF-8',  'username',  'password',  array(PDO::ATTR_EMULATE_PREPARES => false,    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION) ); 

try query like

$query= $pdo$db->prepare("select * from user as u,  leveluser as l  where u.idLevelUser = l.idLevelUser  limit $offset,$rows"); $query->execute(); $result=$articlequery->fetch(pdo::FETCH_ASSOC); 

create the pdo connection like

$db = new PDO('mysql:host=localhost;dbname=testdb;charset=UTF-8', 'username', 'password', array(PDO::ATTR_EMULATE_PREPARES => false,  PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION 

try query like

$query= $pdo->prepare("select * from user as u, leveluser as l where u.idLevelUser = l.idLevelUser limit $offset,$rows"); $query->execute(); $result=$articlequery->fetch(pdo::FETCH_ASSOC); 

create the pdo connection like

$db = new PDO('mysql:host=localhost;dbname=testdb;charset=UTF-8',  'username',  'password',  array(PDO::ATTR_EMULATE_PREPARES => false,   PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION) ); 

try query like

$query= $db->prepare("select * from user as u,  leveluser as l  where u.idLevelUser = l.idLevelUser  limit $offset,$rows"); $query->execute(); $result=$articlequery->fetch(pdo::FETCH_ASSOC); 
Source Link
NullPoiиteя
  • 57.3k
  • 23
  • 130
  • 148

create the pdo connection like

$db = new PDO('mysql:host=localhost;dbname=testdb;charset=UTF-8', 'username', 'password', array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION 

try query like

$query= $pdo->prepare("select * from user as u, leveluser as l where u.idLevelUser = l.idLevelUser limit $offset,$rows"); $query->execute(); $result=$articlequery->fetch(pdo::FETCH_ASSOC);