Bug #16415 Updated: mysql_query() function throws away entire variable if it contains "\0"

From: Date: Thu, 04 Apr 2002 11:25:47 +0000
Subject: Bug #16415 Updated: mysql_query() function throws away entire variable if it contains "\0"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-4016@lists.php.net to get a copy of this message
ID: 16415 Updated by: derick@php.net Reported By: kumar@chicagomodular.com -Status: Open +Status: Closed Bug Type: MySQL related Operating System: OpenBSD PHP Version: 4.1.2 New Comment: Hello, sorry, but we can't provide QA for non-official versions. It is likely that the audit version introduced this bug. Please test php-4.2.0RC2 from www.php.net/~derick . If it still inhibits this fault, please reopen this report. Derick Previous Comments: ------------------------------------------------------------------------ [2002-04-03 13:35:51] kumar@chicagomodular.com actually running PHP 4.1.2-audit _ configure command:  './configure' '--without-db' '--with-apache=./apache' '--with-mysql=/usr/local' '--with-mcrypt=/usr/local' '--with-zlib=/usr' '--with-db3=/usr/local' '--disable-debug' _ I was doing something unnecessary with preg_replace to a variable -- $var = preg_replace("[\(|\)]","\0",$var); -- before using it in an INSERT query, like so: $SQL = "INSERT into theTable (theField) VALUES ('".$var."')"; mysql_query($SQL,$conn); and all I got was a blank entry for the field insert. Basically, the preg was stripping out "()" parenthesis and leaving me with the string inside the parenthesis. the mysql_query must have seen the "\0" null terminator and thrown away the entire string. When I changed the preg function to: $var = preg_replace("[\(|\)]","",$var); everything worked the way it was supposed to. I know there was no good reason for me to replace with a null terminator but maybe this is a bug? when I printed the variable out to debug I could see the string, minus the parenthesis, as I intended. this is what left me confused for quite some time. maybe this isn't a bug but it's definitely only happening in the mysql_query function, not PHP, so I thought I should report it. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16415&edit=1

« previous php.bugs (#4016) next »