Re: PHP + SQLite - Issues with update

From: Date: Fri, 21 Oct 2011 05:43:44 +0000
Subject: Re: PHP + SQLite - Issues with update
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-48057@lists.php.net to get a copy of this message
Prashant Prabhudesai wrote: > Hello, > > > I am running into some issues trying to update a column in a table in a > SQLite database using PHP on Windows and was hoping could get some help on > this mailer. > > > Here is the create and insert statement - > > > CREATE TABLE SERVER ( > IPAddress varchar(100) not null unique primary key, > Token varchar(100) unique > ); > > > INSERT INTO SERVER (IPAddress, Token) VALUES > ('192.168.1.100', ''); > > > I am trying to update the Token field using the following code - > > > [snip] > > > $db = new SQLiteDatabase('db/reg.s3db'); > > > $intoken = uniqid(); > > > $db->query("update SERVER set Token = '$intoken'"); > > > $res = $db->query("select * from SERVER"); > > > $row = $res->fecth(); > > > $outtoken = $row['Token']; > > > echo $outtoken; > > > [snip] > > > After the script exits successfully I inspect the value in the Token > column and its empty. But the echo statement in the snippet above prints > the proper value. > > > Interestingly, if I error out the script with a syntax error or some such > after the update but before it exits, the value shows up in the Token > column. > > > Any idea what is happening here and I need to do here. Seems like there is > some sort of flush that needs to happen which happens only if the script > errors out. > > > Any help is appreciated. > > > Thanks, > Prashant. Spelling matters :-) $row = $res->fecth(); << Wrong $row = $res->fetch(); << Right Cheers -- David Robley Caterpillar: Scratching post. Today is Prickle-Prickle, the 2nd day of The Aftermath in the YOLD 3177.

« previous php.db (#48057) next »