Re: DB : inserting text with embedded "

From: Date: Tue, 09 Jan 2001 13:22:58 +0000
Subject: Re: DB : inserting text with embedded "
References: 1 2  Groups: php.pear 
Request: Send a blank email to php-pear+get-885@lists.php.net to get a copy of this message
Mark Kirkwood wrote: > > Hi all, > > This may be a silly question...but I am trying to debug my PEAR DB based > session handler... it has severe problems with handling string variables.... > I traced this to a failure to insert in value like 'varxxx|s:4:"1234" ;' > into > the sessions table > > The code is part of a sesion handler : > > function sess_write($key, $val) { > global $SESS_CON, $SESS_DBH, $SESS_LIFE; > > $expiry = time() + $SESS_LIFE; > $value = addslashes($val) > > $qry = "INSERT INTO sessions VALUES " . > "('$key', $expiry, '" . $value . > "')"; > $parsedqry = $SESS_CON->prepare($qry); > $qid = $SESS_CON->execute($parsedqry); > return $qid; > > The insert is failing with an error "parse error at object" just after the > the execute statement line. > > I am using Postgres 7.1 as my db... (using the native pgexec call works fine ) > > Any suggestions would be welcome Try this: $qry = "INSERT INTO sessions VALUES (?, ?, ?)"; $parsedqry = $SESS_CON->prepare($qry); $qid = $SESS_CON->execute($parsedqry, array($key, $expiry, $value)); - Stig

« previous php.pear (#885) next »