Please can i pick somebodys brains with some MySQL issues i am having...
I have a table - customers
and a field i need to update - lock
the row can be identified by a field called - name
i am trying to use
$sqlquery = "UPDATE `customers` SET `lock` = `$currentuser` WHERE `name` = `$name`";
but every way i try and do this, i get syntax errors or Database Error (1054): Unknown column '*name*' in 'where clause'
where *name* is the name of whatever customer i am trying to update.
Does anyone have a clue how to fix this?
Cheers in advance!
Calling MySQL eggheads!
Moderator: Forum Moderators
I don't do MySQL that often as I work with the M$ varieties, but the little bit I have done I don't remember needing apostrophes except when sending a string.
or
Code: Select all
UPDATE customers
SET lock = $currentuser
WHERE name = '$name'
Code: Select all
UPDATE customers
SET lock = 1234
WHERE name = 'ProfHawking'
-
- Zombie
- Posts: 2101
- Joined: February 20th, 2005, 21:31
Soo close! By using the slanty apostrophes on the column names and normal apostrophes on the variables then it no longer gives any errors:Stoat wrote:Is that your actual query? Because if it's in `slanty apostrophes` it will assume it's a database element rather than a string.
$sqlquery = "UPDATE `customers` SET `lock` = '$currentuser' WHERE `name` = '$name'";
$sqlquery = "UPDATE `customers` SET `lock` = '$currentuser' WHERE `name` = '$name'";
HOWEVER, it does not actually write anything into the database!!!
even though it has all the variables correct. If i print the query it comes back
UPDATE `customers` SET `lock` = 'rob' WHERE `name` = 'Maxnett Ltd'
Any ideas?
my old scripts used REPLACE INTO, is that a no longer supported method?
This doesn't work im afraid, it must need some kind of separating, otherwise it gives a syntax error.Fear wrote:I don't do MySQL that often as I work with the M$ varieties, but the little bit I have done I don't remember needing apostrophes except when sending a string.
orCode: Select all
UPDATE customers SET lock = $currentuser WHERE name = '$name'
Code: Select all
UPDATE customers SET lock = 1234 WHERE name = 'ProfHawking'
-
- Zombie
- Posts: 2101
- Joined: February 20th, 2005, 21:31