Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Reindl Harald
Am 20.09.2011 01:23, schrieb Dotan Cohen: > On Tue, Sep 20, 2011 at 01:48, Reindl Harald wrote: >> i would use a samll class holding the db-connection with >> insert/update-methods >> pass the whole record-array, lokk what field types are used in the table >> and use intval(), doubleval() or my

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Dotan Cohen
On Tue, Sep 20, 2011 at 01:48, Reindl Harald wrote: > i would use a samll class holding the db-connection with insert/update-methods > pass the whole record-array, lokk what field types are used in the table > and use intval(), doubleval() or mysql_real_escape-String > By the way, the database co

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Dotan Cohen
On Tue, Sep 20, 2011 at 01:48, Reindl Harald wrote: > i would use a samll class holding the db-connection with insert/update-methods > pass the whole record-array, lokk what field types are used in the table > and use intval(), doubleval() or mysql_real_escape-String > > so you never write "insert

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Dotan Cohen
On Tue, Sep 20, 2011 at 02:09, Hank wrote: >> >> I want to be sure that all variables in the query are escaped. I don't >> trust myself or anyone else to do this to every variable right before >> the query: >> $someVar=mysql_real_escape_string($someVar); >> > > But you're doing exactly that right

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Hank
> > > I want to be sure that all variables in the query are escaped. I don't > trust myself or anyone else to do this to every variable right before > the query: > $someVar=mysql_real_escape_string($someVar); > > But you're doing exactly that right before the query anyway with: $M[username]=mysql_

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Reindl Harald
Am 20.09.2011 00:39, schrieb Dotan Cohen: > On Tue, Sep 20, 2011 at 01:11, Hank wrote: >> Best of both worlds: >>> $username=$_POST['username']; >>> // do some stuff with username here >>> $M=array(); // Array of things to be inserted into MySQL >>> $M[username]=mysql_real_escape_string($userna

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Dotan Cohen
On Tue, Sep 20, 2011 at 01:11, Hank wrote: > Best of both worlds: >> $username=$_POST['username']; >> // do some stuff with username here >> $M=array();  // Array of things to be inserted into MySQL >> $M[username]=mysql_real_escape_string($username); // Everything that >> goes into $M is escaped

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Hank
Best of both worlds: > $username=$_POST['username']; > // do some stuff with username here > $M=array(); // Array of things to be inserted into MySQL > $M[username]=mysql_real_escape_string($username); // Everything that > goes into $M is escaped > $query="INSERT INTO table (username) VALUES ('{$M

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Dotan Cohen
On Mon, Sep 19, 2011 at 18:11, Reindl Harald wrote: > it is not because it is clear that it is sanitized instead hope and pray > thousands of layers somewhere else did it - for a inline-query the best > solution, if you are using a framework you will never have the "insert into" > at this place! >

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Reindl Harald
Am 19.09.2011 16:55, schrieb Hank: >> >> what ugly style - if it is not numeric and you throw it to the database >> you are one of the many with a sql-injection because if you are get >> ivalid values until there you have done no sanitize before and do not here >> >> > It's a matter of opinion.

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Hank
> > what ugly style - if it is not numeric and you throw it to the database > you are one of the many with a sql-injection because if you are get > ivalid values until there you have done no sanitize before and do not here > > It's a matter of opinion. I never said the data wasn't sanitized (it is

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-19 Thread Dotan Cohen
On Mon, Sep 19, 2011 at 07:47, Reindl Harald wrote: > what ugly style - if it is not numeric and you throw it to the database > you are one of the many with a sql-injection because if you are get > ivalid values until there you have done no sanitize before and do not here > > $sql="INSERT into tab

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-18 Thread Dotan Cohen
On Mon, Sep 19, 2011 at 04:00, Hank wrote: > I agree with Brandon's suggestions, I would just add when using numeric > types in PHP statements where you have a variable replacement, for instance: > > $sql="INSERT into table VALUES ('$id','$val')"; > > where $id is a numeric variable in PHP and a n

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-18 Thread Reindl Harald
Am 19.09.2011 03:00, schrieb Hank: > I agree with Brandon's suggestions, I would just add when using numeric > types in PHP statements where you have a variable replacement, for instance: > > $sql="INSERT into table VALUES ('$id','$val')"; > > where $id is a numeric variable in PHP and a numeri

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-18 Thread Hank
On Sun, Sep 18, 2011 at 12:28 PM, Dotan Cohen wrote: > On Sun, Sep 18, 2011 at 17:44, Brandon Phelps wrote: > > Personally I don't use any quotes for the numeric types, and single > quotes > > for everything else. Ie: > > > > Thanks, Brandon. I understand then that quote type is a matter of > t

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-18 Thread Dotan Cohen
On Sun, Sep 18, 2011 at 17:44, Brandon Phelps wrote: > Personally I don't use any quotes for the numeric types, and single quotes > for everything else.  Ie: > Thanks, Brandon. I understand then that quote type is a matter of taste. I always use double quotes in PHP and I've only recently started

Re: Quotes around INSERT and SELECT statements' arguments from the mysql CLI and PHP

2011-09-18 Thread Brandon Phelps
`varchar_field` = 'Test' WHERE `id` = 3" And some people prefer to put numeric fields in quotes as well, although it is not necessary: UPDATE mytable SET int_field = '5' WHERE id = '3'; On 9/18/11 5:00 AM, Dotan Cohen wrote: I am somewhat confused as to t

Re: insert and select

2002-03-15 Thread c.smart
_Reference.html#Miscellaneous_functions Javier Gloria wrote: > Hi: > > how i can insert and select information at the same time. > > first i want to insert the information relative to the client and after > that i need to select the same information on the

insert and select

2002-03-15 Thread Javier Gloria
Hi: how i can insert and select information at the same time. first i want to insert the information relative to the client and after that i need to select the same information on the same query. that is possible _ Do You Yahoo

Lock with update,insert and select

2001-02-14 Thread chchen
hi all. i have a problem. i use mysql-3.23.32 on FreeBSD4.2-release my project need to update/insert some datas into mysql every 5mins. but sometims these datas are lots. so i need to reduce the update/insert time as short as possible, prevent it run over 5mins. i found out that if i use LOCK