RE: Concat 3 fields in a query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux