Re: [PHP] String variable
On Sun, Jan 11, 2009 at 8:59 AM, MikeP mpel...@princeton.edu wrote: Hello, I am trying yo get THIS: where ref_id = '1234' from this. $where=where ref_id=.'$Reference[$x][ref_id]'; but i certainly have a quote problem. Any help? Thanks Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Looks like you're missing the single tics around ref_id. In your example you'd want one of these: $where=where ref_id=.'{$Reference[$x]['ref_id']}; $where=where ref_id=.$Reference[$x]['ref_id']; $where=sprintf(where ref_id=%d, (int)$Reference[$x]['ref_id']); -- use this one or else! (sql injection) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String variable
On Sun, 2009-01-11 at 08:59 -0500, MikeP wrote: Hello, I am trying yo get THIS: where ref_id = '1234' from this. $where=where ref_id=.'$Reference[$x][ref_id]'; but i certainly have a quote problem. Any help? Thanks Mike It should look like this: $where=where ref_id='{$Reference[$x][ref_id]}'; Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String variable
On Sun, 2009-01-11 at 14:36 +, Ashley Sheridan wrote: On Sun, 2009-01-11 at 08:59 -0500, MikeP wrote: Hello, I am trying yo get THIS: where ref_id = '1234' from this. $where=where ref_id=.'$Reference[$x][ref_id]'; but i certainly have a quote problem. Any help? Thanks Mike It should look like this: $where=where ref_id='{$Reference[$x][ref_id]}'; Ash www.ashleysheridan.co.uk Sorry, it should look like this: $where=where ref_id='{$Reference[$x][ref_id]}'; I missed taking an extra quote mark out Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String variable
Ashley Sheridan wrote: On Sun, 2009-01-11 at 14:36 +, Ashley Sheridan wrote: On Sun, 2009-01-11 at 08:59 -0500, MikeP wrote: Hello, I am trying yo get THIS: where ref_id = '1234' from this. $where=where ref_id=.'$Reference[$x][ref_id]'; but i certainly have a quote problem. Any help? Thanks Mike It should look like this: $where=where ref_id='{$Reference[$x][ref_id]}'; Ash www.ashleysheridan.co.uk Sorry, it should look like this: $where=where ref_id='{$Reference[$x][ref_id]}'; I missed taking an extra quote mark out Ash www.ashleysheridan.co.uk actually unless ref_id is a constant (which i doublt) you may be best going with: $where = WHERE ref_id=' . $Reference[$x]['ref_id'] . '; keep the php and sql seperate and you'll find it much easier to see in you're editor (imho) :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String variable
2009/1/11 Ashley Sheridan a...@ashleysheridan.co.uk: On Sun, 2009-01-11 at 14:36 +, Ashley Sheridan wrote: On Sun, 2009-01-11 at 08:59 -0500, MikeP wrote: Hello, I am trying yo get THIS: where ref_id = '1234' from this. $where=where ref_id=.'$Reference[$x][ref_id]'; but i certainly have a quote problem. Any help? Thanks Mike It should look like this: $where=where ref_id='{$Reference[$x][ref_id]}'; Ash www.ashleysheridan.co.uk Sorry, it should look like this: $where=where ref_id='{$Reference[$x][ref_id]}'; I missed taking an extra quote mark out Closer, but still not quite there. For encapsulation in the string, it should look like: $where = where ref_is='{$Reference[$x]['ref_id']}'; Someone else mentioned casting to int first as well to sanitize, which is also a good idea. Torben Ash www.ashleysheridan.co.uk -- Torben Wilson tor...@2powerweb.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php