the concat_ws command is mysql specific...it only works in a sql statement.
if you want to do this in code then
PO_Date= $_POST['PO_Year'].'-'.$_POST['PO_Month'].'-'.$_POST['PO_Day'])';
will work
bastien
From: Khristopher_Klaich@xxxxxxxxxxxxxxxxx
To: <php-db@xxxxxxxxxxxxx>
Subject: RE: Concat 3 fields in a query
Date: Fri, 3 Dec 2004 13:21:50 -0500
Thanks to all that responded to this thread I learned from it.
I actually validate the data before it even gets to the insert or update
statment to make sure there are no evil characters out there trying to
cause me pain.
I do have one more question I fixed the insert query now onto the update
query where the syntax is a little different so from your example I should
be able to do this then correct?
PO_Date= '"
concat_ws('-',$_POST['PO_Year'],$_POST['PO_Month'],$_POST['PO_Day'])'"
or would I not need the ' around all of them. Any good sites out there to
explain when to use ' and when to use " sorry kind of a newbie but
appreicate all of the help maybe one day I can return the favor.
Khris
"Norland, Martin" <Martin.Norland@xxxxxxxxxx>
12/03/2004 12:03 PM
Please respond to
<php-db@xxxxxxxxxxxxx>
To
<php-db@xxxxxxxxxxxxx>
cc
Subject
RE: Concat 3 fields in a query
-----Original Message-----
From: Bastien Koert [mailto:bastien_k@xxxxxxxxxxx]
>
concat_ws('-',{$_POST['PO_Year']},{$_POST['PO_Month']},{$_POST['PO_Day']
})
I'm pretty sure this will error because of the unneccessary {}'s around
the POST array items. PHP really doesn't like you using extra curlies
around variables, it's very picky.
Instead:
concat_ws('-',$_POST['PO_Year'],$_POST['PO_Month'],$_POST['PO_Day'])
Not trying to be anal, I've just been bitten many a time as I do lots of
dynamic class and variable coding, and ritualistically try to thunk
curlies around most everything.
> ps. I strongly recommend validating data before you insert into the db
I couldn't agree more.
Cheers,
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php