How to echo query result using PHP mysql (PDO) -


this may seem silly, can't figure out how simple thing in spite of googling.

i have functional php script queries mysql database check boolean value. script contains code:

$sql = "select truefalse mydb bilbobaggins=:bilbobaggins";  $query = $db->prepare($sql);  try {  $query->execute(array(          ':bilbobaggins' => $bilbobaggins  ));  } catch (exception $e) {  echo "query failed. " . ($e->getmessage()); $db = null; die;  } 

all i'm trying have result of query echo script, such example, if put

http://www.myurl.com/myscript.php?bilbobaggins=user32984329842 

into browser, return either 1 or 0 in text format.

i suspect need change line:

$query->execute(array( 

to like:

print $query->execute(array( 

but not work.

any appreciated. thanks.

try like...

<?php $sql = "select truefalse mydb `key`=:key"; $stmt = $db->prepare($sql); $stmt->execute(array('key' => $key)); header('content-type: text/plain;'); echo($stmt->fetchcolumn()); 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -