syntax for UPDATE statment?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mudge.steve
Forum Newbie
Posts: 10
Joined: Thu Apr 22, 2010 3:28 pm

syntax for UPDATE statment?

Post by mudge.steve »

I am trying to update a new field with a field named 'filename' but only want the left charactors (length of what it is -4)

I am a newbi! Please help

UPDATE photographs SET basefilename = substr(filename,0,lengh(filename)-4)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: syntax for UPDATE statment?

Post by Christopher »

You misspelled "lengh" ... it is length. Also, make sure you are not mixing up SQL functions and PHP functions. You can put SQL functions into the query string, but PHP functions need to be called in the script. The output of the PHP functions is put into a variable which is then put in the query string.
(#10850)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: syntax for UPDATE statment?

Post by requinix »

Neither "substr" nor "lengh" are MySQL functions.

Luckily MID and LENGTH are.
Post Reply