update a mysql record php issue
Moderator: General Moderators
Re: update a mysql record php issue
Precisely as the error indicates, $row is undefined. I'm not sure what value that is meant to contain, but there's no $row = anywhere in that code.
Re: update a mysql record php issue
$row is defined only within the scope of that function, not in the global scope, which is where you're trying to echo the description.
http://php.net/manual/en/language.variables.scope.php
Additionally, description is not part of your select statement, so wouldn't be returned anyway.
http://php.net/manual/en/language.variables.scope.php
Additionally, description is not part of your select statement, so wouldn't be returned anyway.
Re: update a mysql record php issue
You've executed the query but you never fetched the results.
Re: update a mysql record php issue
You still need to call fetch or fetchAll. Incidentally, you can pass the fetch mode as an argument to either of those methods.
Re: update a mysql record php issue
Code: Select all
$sql=$dbh->prepare("SELECT
e.emp_id
, t.task_id
, t.description
, t.status
FROM employee e
JOIN assignment a ON e.emp_id = a.emp_id
JOIN task t ON a.task_id = t.task_id
WHERE e.emp_id = ?");
$sql->execute(array($_SESSION['user']));
$row = $sql->fetch(PDO::FETCH_ASSOC);
Re: update a mysql record php issue
Your query is using session data, so what's in the address bar is irrelevant.ianhaney wrote:in my address bar, it has task_id=3 but the description it is pulling out is task_id
Re: update a mysql record php issue
The short answer is you'd want $_GET['task_id'], though there may be other considerations at play (ie. does the current user have permission to access the task in question, etc)