Re[4]: [PHP-WIN] Converting apostrophes for insertion into Or acle

From: Date: Tue, 06 Feb 2001 16:40:25 +0000
Subject: Re[4]: [PHP-WIN] Converting apostrophes for insertion into Or acle
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-5415@lists.php.net to get a copy of this message
John: Then, what if you do this: function fix_value($value) { if (!isset($value) || $value=="") { $value_sql="null" } else { $value_sql='"'.$value.'"'; } return $value_sql; } $SQL=" INSERT into cfull2.tbl_dl_customers (CUSTID_NUM, SHORT_NAME, FIELD3, ...) VALUES(fix_value($Max_ID), fix_value($SHORT_NAME), fix_value($FIELD3), ...) "; Saludos, Pablo Vera _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Tuesday, February 06, 2001, 8:26:41 AM, John wrote: AJ> The only problem with that is that I truncated the actual SQL statement AJ> which has about 15 variables it is updating... the combinations are AJ> dizzying... AJ> --------------------- AJ> John Asendorf - jasendorf@lcounty.com AJ> Web Applications Developer AJ> http://www.lcounty.com - NEW FEATURES ADDED DAILY! AJ> Licking County, Ohio, USA AJ> 740-349-3631 AJ> The benefit to the government of replacing all $1 Federal Reserve notes with AJ> $1 coins would be $522.2 million per year, according to estimates of the AJ> General Accouting Office released on April 7, 2000. >> -----Original Message----- >> From: Pablo Vera [mailto:pvz@vercan.com] >> Sent: Monday, February 05, 2001 6:06 PM >> To: Php-Windows (E-mail) >> Subject: Re[2]: [PHP-WIN] Converting apostrophes for insertion into >> Oracle >> >> >> John: >> >> You could do something like this (I'm not sure if this will work): >> >> if (!isset($SHORT_NAME) || $SHORT_NAME=="") { >> $SQL=" >> INSERT into cfull2.tbl_dl_customers (CUSTID_NUM, SHORT_NAME) >> VALUES(\"$Max_ID\", null) >> "; >> } else { >> $SQL=" >> INSERT into cfull2.tbl_dl_customers (CUSTID_NUM, SHORT_NAME) >> VALUES(\"$Max_ID\", \"$SHORT_NAME\") >> "; >> } >> >> Saludos, >> Pablo >> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >> >> Monday, February 05, 2001, 3:42:12 PM, John wrote: >> >> AJ> The error comes up when you have something like this >> >> AJ> INSERT into cfull2.tbl_dl_customers (CUSTID_NUM, SHORT_NAME) >> AJ> VALUES("$Max_ID", "$SHORT_NAME") >> >> AJ> and $SHORT_NAME is empty so the SQL looks like this >> >> AJ> INSERT into cfull2.tbl_dl_customers (CUSTID_NUM, >> SHORT_NAME) VALUES("20002", >> AJ> "") //doesn't work >> >> >> >> AJ> If I use the single quote or apostrophe, it works fine.... >> >> AJ> INSERT into cfull2.tbl_dl_customers (CUSTID_NUM, >> SHORT_NAME) VALUES('20002', >> AJ> '') //works fine >> >> >> >> >> >> -----Original Message----- >> >> From: Svensson, B.A.T. [mailto:B.A.T.Svensson@lumc.nl] >> >> Sent: Monday, February 05, 2001 4:39 PM >> >> To: Asendorf, John >> >> Subject: RE: [PHP-WIN] Converting apostrophes for insertion >> >> into Oracle >> >> >> >> >> >> That seams to be related to the name of the attribute(?) >> >> (filed), not the >> >> content of the attribute (filed). Or do I misinterpret the >> >> error message? >> >> >> >> >-----Original Message----- >> >> >From: Asendorf, John [mailto:JAsendorf@lcounty.com] >> >> >Sent: Monday, February 05, 2001 10:21 PM >> >> >To: Pablo Vera; Php-Windows (E-mail) >> >> >Subject: RE: [PHP-WIN] Converting apostrophes for insertion >> >> into Oracle >> >> > >> >> > >> >> >Hi Pablo >> >> > >> >> >To answer your question, yes... It doesn't seem to like that >> >> >because the >> >> >field can be empty... for some reason Oracle won't allow you >> >> >to have an >> >> >empty field enclosed by two "'s... ORA-01741: illegal >> zero-length >> >> >identifier >> >> > >> >> >John >> >> > >> >> >> John: >> >> >> >> >> >> When you say that your SQL statement has apostrophes, you >> >> mean single >> >> >> quotes enclosing a string value ?, if this is the case, >> why not try >> >> >> changing the single quotes in your SQL for double quotes. >> >> >> >> >> >> Saludos, >> >> >> Pablo >> >> >> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >> >> >> >> >> >> Monday, February 05, 2001, 3:03:21 PM, John wrote: >> >> >> >> >> >> AJ> I've got a web form that might have someone entering >> >> apostrophes. >> >> >> AJ> Unfortunately, my SQL statement has apostrophes in it and >> >> >> it seems to be >> >> >> AJ> messing it up... >> >> >> >> >> >> AJ> Any suggestions other than a regex (which I could >> do myself)? >> >> >> >> >> >> AJ> John >> >> >> >> >> >> AJ> --------------------- >> >> >> AJ> John Asendorf - jasendorf@lcounty.com >> >> >> AJ> Web Applications Developer >> >> >> AJ> http://www.lcounty.com - NEW >> >> >> AJ> FEATURES ADDED DAILY! >> >> >> AJ> Licking County, Ohio, USA >> >> >> AJ> 740-349-3631 >> >> >> >> >> >> AJ> The benefit to the government of replacing all $1 Federal >> >> >> Reserve notes with >> >> >> AJ> $1 coins would be $522.2 million per year, according to >> >> >> estimates of the >> >> >> AJ> General Accouting Office released on April 7, 2000. >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> PHP Windows Mailing List (http://www.php.net/) >> >> >> To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net >> >> >> For additional commands, e-mail: php-windows-help@lists.php.net >> >> >> To contact the list administrators, e-mail: >> >> >> php-list-admin@lists.php.net >> >> >> >> >> > >> >> >-- >> >> >PHP Windows Mailing List (http://www.php.net/) >> >> >To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net >> >> >For additional commands, e-mail: php-windows-help@lists.php.net >> >> >To contact the list administrators, e-mail: >> >> >php-list-admin@lists.php.net >> >> > >> >> >> >> >> >> -- >> PHP Windows Mailing List (http://www.php.net/) >> To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net >> For additional commands, e-mail: php-windows-help@lists.php.net >> To contact the list administrators, e-mail: >> php-list-admin@lists.php.net >>

« previous php.windows (#5415) next »