RE: [PHP-DB] Concat 3 fields in a query

From: Date: Fri, 03 Dec 2004 18:21:50 +0000
Subject: RE: [PHP-DB] Concat 3 fields in a query
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-37561@lists.php.net to get a copy of this message
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@STJUDE.ORG> 12/03/2004 12:03 PM Please respond to <php-db@lists.php.net> To <php-db@lists.php.net> cc Subject RE: [PHP-DB] Concat 3 fields in a query -----Original Message----- From: Bastien Koert [mailto:bastien_k@hotmail.com] > 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

« previous php.db (#37561) next »