Jump to content

PDO Echoing Column


radioactive

Recommended Posts

I want to echo the contents of column 4 for my username only, and it doesn't show anything. I can do if ($memberQuery->fetchColumn(4) < 2) though.

 

$host = 'localhost';
$database = '';
$db_username = '';
$db_password = '';

if (($db = new PDO("mysql:host=$host;dbname=$database", $db_username, $db_password)) == NULL) {
echo $db->getMessage();
}

$memberQuery = $db->prepare("SELECT * FROM members WHERE username=:username");
$memberQuery->execute(array(':username' => $_SESSION['username']));
$result = $memberQuery->fetchColumn(4);
echo "$result";

Link to comment
https://forums.phpfreaks.com/topic/250751-pdo-echoing-column/
Share on other sites

This is my changed code, but nothing is echoing still.

 

$memberQuery = $db->prepare("SELECT expiry FROM members WHERE username=:username");
$memberQuery->execute(array(':username' => $_SESSION['username']));
$result = $memberQuery->fetchColumn(0);
echo "$result";

Link to comment
https://forums.phpfreaks.com/topic/250751-pdo-echoing-column/#findComment-1286493
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.