
Originally Posted by
Lucie
$handlername = $_GET['handlerName'];
$startdate = $_GET['startDate'];
$animalname = $_GET['animalName'];
$ownerreview = $_GET['reviewtext'];
I really hope you aren't using that data directly within the query. That's asking for trouble.
$sql1 ="UPDATE NK_Booking SET
reviewtext='$ownerreview'
WHERE
animalName='$animalname' AND
handlerName='$handlername' AND
startDate='$startdate'";
Yes, that's better. The WHERE clause is an expression that must evaluate to a boolean; commas aren't legal.
The error has now changed to: Error adding new review: Unknown column 'handlerName' in 'where clause'.
Is this because the handlerName field in not in the table NK_Booking? It is in Nk_BookingHandler.
Yes.
Do i therefore need some kind of inner join?
Yes.
And how and where would I do this?!!
In the WHERE clause, using a subquery.
It's difficult to be specific because you haven't stated the relationship between NK_Booking and Nk_BookingHandler, but it would be something like:
Code:
"UPDATE NK_Booking"
. " SET reviewtext=$ownerreview"
. " WHERE animalName='$animalname'"
. " AND startDate='$startdate'"
. " AND <foreignKey>=(SELECT <primaryKey>"
. " FROM Nk_BookingHandler"
. " WHERE handlerName='$handlername')"
Subqueries as scalar operands must only return a single value: one attribute and one tuple.
Mike
SQL. It's been a while...
Bookmarks