Re: 4 hours staring - can't see clear.

From: Date: Thu, 12 Jun 2003 08:39:02 +0000
Subject: Re: 4 hours staring - can't see clear.
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-151208@lists.php.net to get a copy of this message
On Wed, 2003-06-11 at 21:00, John Taylor-Johnston wrote: > Lars, > > Thanks. I am getting this error however: > > Parse error: parse error, expecting T_STRING' or > T_VARIABLE' or `T_NUM_STRING' in > > It does not like addslashes() because of the {}? What is a sensible work around? Or do I even > need addslashes?? > > if ($found) > { > $sql = "INSERT INTO $dbtable > > (RNum,YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,SR,PL,PR,JR,VNum,INum,DT,PG,LG,SF,OL,KW,AUS,GEO,AN,RB,CO,RR) > VALUES > > ('{addslashes($record['RNum'])}','{addslashes($record['YR'])}','{addslashes($record['AU'])}','{addslashes($record['ST'])}','{addslashes($record['SD'])}','{addslashes($record['SC'])}','{addslashes($record['BT'])}','{addslashes($record['BD'])}','{addslashes($record['BC'])}','{addslashes($record['AT'])}','{addslashes($record['AD'])}','{addslashes($record['AC'])}','{addslashes($record['SR'])}','{addslashes($record['PL'])}','{addslashes($record['PR'])}','{addslashes($record['JR'])}','{addslashes($record['VNum'])}','{addslashes($record['INum'])}','{addslashes($record['DT'])}','{addslashes($record['PG'])}','{addslashes($record['LG'])}','{addslashes($record['SF'])}','{addslashes($record['OL'])}','{addslashes($record['KW'])}','{addslashes($record['AUS'])}','{addslashes($record['GEO'])}','{addslashes($record['AN'])}','{addslashes($record['RB'])}','{addslashes($record['CO'])}','{addslashes($record['RR'])}')"; > echo "$sql<hr>\n"; > } Ah...in this case, the addslashes() is being called from within the quotes, so it won't get called. In this case, I would suggest moving it to the assignment above: if (isset($var[$key]['Option'])) { // Flag that we got one this time round. $found = true; // Get the translated name from $var. $record[$var[$key]['Option']] = addslashes(trim($val)); } ...that way, you know it's been called on everything, and you don't have to hunt around and change it in a bunch of places if you decide on something else later on. Cheers, Torben -- Torben Wilson <torben@php.net> +1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com -----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----

« previous php.general (#151208) next »