Re: concat woes
| From: | haliphax | Date: | Thu, 05 Mar 2009 22:51:46 +0000 |
| Subject: | Re: concat woes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-289412@lists.php.net to get a copy of this message | ||
On Thu, Mar 5, 2009 at 4:34 PM, PJ <af.gourmet@videotron.ca> wrote:
> Here we go again!
> I'm trying to do some form entry verification and am trying to figure
> out how to verify if there are 4 fields entered:
> f_nameIN, l_nameIN, f_name2IN, l_name2IN
> Verifying for each is ok, but somewhat tortured and long. I thought of
> using CONCAT_WS but it doesn't seem to listen to me.
> The manual is not very explicit as to where it can be used and by the
> examples, it would seem that it can only be used in select statements.
> Seems a little silly, no?
> Here is what I found so far.
> echo $f_nameIN," ", $l_nameIN;
> returns joe whatever - ok, fine.
> Obviously the string contains something. Right.
> Now try this
> $Author = CONCAT_WS(" ", $f_nameIN, $l_nameIN);
> echo $Author;
> and it's a flop.
> Am I missing a bracket, curly bracket or a baseball bat?
> I thought maybe I should add AS Author - but that only seems to work in
> a select statement. :'(
> Help?
I believe you're mixing your T-SQL with your PHP. Sort of like getting
chocolate in your peanut butter, but not half as delicious.
CONCAT_WS is a MySQL server-side function. It cannot be called
directly from PHP, but rather via a database call performed **by**
PHP.
Also--PHP has the nifty "dot" (.) operator for concatenating strings. Try this:
$Author = $f_nameIN . ' ' . $l_nameIN;
echo $Author;
Hope this helps,
--
// Todd