Why can’t i pull this field pID from the the database?
I have the following php:
<?php
// Get course information cID, prefix, code and dept info : name
$cID = filter_input(INPUT_GET, 'cID', FILTER_SANITIZE_NUMBER_INT);
if(!$cID) {
echo "No cID specified.";
exit;
}
require_once('inc/dbc1.php');
$pdo4 = new PDO('mysql:host=localhost;dbname=###', $username, $password);
$pdo4->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sth4 = $pdo4->prepare('
SELECT fname, lname
FROM Course Cou, Comment Comm, Professor P
WHERE Cou.cID = ?
AND P.pID = Comm.pID
GROUP BY concat(fname, lname);
');
$sth4->execute(array(
$cID
));
?>
HTML/PHP
<a href='prof.php?pID={$row['pID']}' title='Drexel Professor Comments for {$row['fname']} {$row['lname']}'>

The above is pulling the fname and lname fields, but the first call for pID is not being pulled.
-
If I add pID to the select statement,
it gives me the ambiguous pID error.
Anyone??
You need to add the field to the select statement, otherwise it won’t be part of the result set.
Then make it unambiguous:
should work.