Article View: comp.os.vms
Article #70Re: PHP "Features"
From: Lawrence D’Oliveiro
Date: Sat, 24 Oct 2026 22:43
Date: Sat, 24 Oct 2026 22:43
44 lines
2965 bytes
2965 bytes
On Sat, 24 Oct 2026 11:59:30 -0400, Arne Vajhøj wrote:
> Always === is a good workaround.
A workaround is still a workaround. The weak typing that led to its
necessity is not “good”.
> First note that the recommended way to use mysqli is to use prepare.
> mysqli_real_escape_string only exist for extraordinary
> circumstances.
What do you use for LIKE and REGEXP clauses?
> But there is a reason that the function is called escape
> and not escape_and_quote - it just escapes - it does not quote.
You need a function that turns an object in the application language
into an appropriate literal in the query language, including quotes
where appropriate but leaving them out if not. For example, whatever
in your language maps to “NULL” in SQL must never be quoted!
For example, here’s function I’ve been using in Python code, that
does strictly standard SQL quoting:
def sql_string(s) :
"returns an SQL string literal that evaluates to s."
if s == None :
q = "null"
elif isinstance(s, int) :
q = "%d" % s
elif isinstance(s, (bytes, bytearray)) :
q = "X'" + "".join("%02x" % d for d in s) + "'"
elif isinstance(s, str) :
q = "'" + s.replace("'", "''") + "'"
else :
raise TypeError("can only convert bytes, str, int or None types")
#end if
return q
#end sql_string
> PHP mysqli_real_escape_string put backslashes in front of
> problematic characters.
Note that backslash-escapes are not standard SQL.
Technical Details
Message-ID:
<11bjcal$340l8$9@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11bcbi1$k068$1@dont-email.me> <nk1gv8F1eecU1@mid.individual.net> <11bgih8$f7a$1@reader2.panix.com> <nk2bhaF5j2sU1@mid.individual.net> <11bh3ei$19g$1@reader2.panix.com> <11bi7bg$2mdi4$1@dont-email.me> <11bikkl$2rllh$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Lawrence D’Oliveiro <ldo@nz.invalid> Newsgroups: comp.os.vms Subject: Re: PHP "Features" Date: Sat, 24 Oct 2026 22:43:34 -0000 (UTC) Organization: A noiseless patient Spider Lines: 44 Message-ID: <11bjcal$340l8$9@dont-email.me> References: <11bcbi1$k068$1@dont-email.me> <nk1gv8F1eecU1@mid.individual.net> <11bgih8$f7a$1@reader2.panix.com> <nk2bhaF5j2sU1@mid.individual.net> <11bh3ei$19g$1@reader2.panix.com> <11bi7bg$2mdi4$1@dont-email.me> <11bikkl$2rllh$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 24 Oct 2026 22:43:34 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3277480"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19cXdm1B8VIsCSrWA/EfqCU"; posting-host="2f0c6f23b3422283e8fcbe6e904c474e" User-Agent: Pan/0.165 (Kostiantynivka) Cancel-Lock: sha1:Yshh1u1phV6YllA3EahCiLDFb1s= sha256:0EM1YE5+s8rCWbdE1HudWcheV1+eBSVLQdMH0+wEVYo= sha1:Cq5lHKkDeZ6zFov/MY2ro4kAbns= sha256:RrPIHfGo/e4H1FhaAg+3hIp5nVRRpn2Vw9wikdhPxk0=