This is a discussion on Simple question, but I`m puzzled :( within the PHP Language forums, part of the PHP Programming Forums category; Hi! I`ve got a simple question but I`m puzzled:( When I create variable: for example $query for query ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi!
I`ve got a simple question but I`m puzzled:( When I create variable: for example $query for query to MySQL its obvieus that I want to use variables. Now should I do something like that: 1) $query = "blahblahblah".$variable1."blahblahblah" ."blahblahblah".$variable2."blahblahblah"; OR 2) $query = "blahblahblah."$variable1."blahblahblah" ."blahblahblah."$variable2."blahblahblah"; It`s the 1st one right? I have to be sure:( TIA -- Best regards, Maciej Nadolski |
|
|||
|
On Sat, 4 Oct 2003 13:31:23 +0000 (UTC), Maciej Nadolski
<usenet@WYTNIJ-TO.nadolski.net> wrote: >Hi! >I`ve got a simple question but I`m puzzled:( When I create variable: for example >$query for query to MySQL its obvieus that I want to use variables. Now should I do >something like that: >1) $query = "blahblahblah".$variable1."blahblahblah" > ."blahblahblah".$variable2."blahblahblah"; >OR >2) $query = "blahblahblah."$variable1."blahblahblah" > ."blahblahblah."$variable2."blahblahblah"; > >It`s the 1st one right? I have to be sure:( The first one is valid PHP, the second one is a syntax error, as PHP would have told you if you'd tried it... -- Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk) Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space) |
|
|||
|
Andy Hassall <andy@andyh.co.uk> wrote in
news:cmjtnvc5efjhqrcknd0gcemirgehu7r4i4@4ax.com: > The first one is valid PHP, the second one is a syntax error, as PHP > would > have told you if you'd tried it... > > -- > Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk) > Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space) > I haven`t run tests yet and I wanted to make sure before them so I asked. Thanks:) -- Pozdrawiam, Maciej Nadolski |
|
|||
|
On Sat, 04 Oct 2003 14:10:28 +0000, Maciej Nadolski wrote:
> Andy Hassall <andy@andyh.co.uk> wrote in > news:cmjtnvc5efjhqrcknd0gcemirgehu7r4i4@4ax.com: > >> The first one is valid PHP, the second one is a syntax error, as PHP >> would >> have told you if you'd tried it... >> >> -- >> Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk) >> Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space) >> > > I haven`t run tests yet and I wanted to make sure before them so I asked. Thanks:) Well why the heck not?? A simple test would've answered your question more quickly than posting to this newsgroup! -- Jeffrey D. Silverman | jeffrey AT jhu DOT edu Johns Hopkins University | Baltimore, MD Website | http://www.wse.jhu.edu/newtnotes/ |
|
|||
|
"Maciej Nadolski" <usenet@WYTNIJ-TO.nadolski.net> wrote in message
news:Xns940A9DE54605Dusenetnadolskinet@193.110.122 .80... > Hi! > I`ve got a simple question but I`m puzzled:( When I create variable: for example > $query for query to MySQL its obvieus that I want to use variables. Now should I do > something like that: > 1) $query = "blahblahblah".$variable1."blahblahblah" > ."blahblahblah".$variable2."blahblahblah"; > OR > 2) $query = "blahblahblah."$variable1."blahblahblah" > ."blahblahblah."$variable2."blahblahblah"; > > It`s the 1st one right? I have to be sure:( What was the point of this question? I ask only because the only difference between your examples would appear to be a typo (concatenation operator inside quotes in second example). - Virgil |
|
|||
|
"Maciej Nadolski" <usenet@WYTNIJ-TO.nadolski.net> wrote in message news:Xns940A9DE54605Dusenetnadolskinet@193.110.122 .80... > Hi! > I`ve got a simple question but I`m puzzled:( When I create variable: for example > $query for query to MySQL its obvieus that I want to use variables. Now should I do > something like that: > 1) $query = "blahblahblah".$variable1."blahblahblah" > ."blahblahblah".$variable2."blahblahblah"; > OR > 2) $query = "blahblahblah."$variable1."blahblahblah" > ."blahblahblah."$variable2."blahblahblah"; > > It`s the 1st one right? I have to be sure:( > TIA > > -- > Best regards, > Maciej Nadolski RTFM. If you did you would see that 1 is valid php and 2 is not, but that neither are partiularly efficient. You are using double quotes where single would suffice: $query = 'blahblahblah'.$variable1.'blahblahblahblahblahbla h' .$variable2.'blahblahblah'; would be favourable. If you really wanted to use doube quotes (maybe your keyboard is broken?) then you could use: $query = "blahblahblah{$variable1}blahblahblah {$variable2}blahblahblah"; but this will be slower as php will be parsing the pre-defined text as well. PS -- Divide By Cucumber Error. Please Reinstall Universe And Reboot |