Bug #18172 Updated: Mysql_query function RLIKE and REGEXP
| From: | sniper@php.net | Date: | Fri, 05 Jul 2002 17:12:53 +0000 |
| Subject: | Bug #18172 Updated: Mysql_query function RLIKE and REGEXP | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-13237@lists.php.net to get a copy of this message | ||
ID: 18172
Updated by: sniper@php.net
Reported By: r.denis@bell.ca
-Status: Open
+Status: Feedback
Bug Type: MySQL related
Operating System: Freebsd/Linux
PHP Version: 4.2.1
New Comment:
Make a SHORT example where you don't use any variables
but the exact same SQL line you tried with the mysql shell.
Previous Comments:
------------------------------------------------------------------------
[2002-07-05 11:49:19] r.denis@bell.ca
Here is a snippit of the actual code;
-----------------------------------------------
<?php
if (!isset($PHP_AUTH_USER) || !zcntlogin) {
header("WWW-Authenticate: Basic realm=\"Bell
Domain\"");
header("HTTP/1.0 401 Unauthorized");
exit;
} else {
$zcntlogin =$PHP_AUTH_USER;
//echo $zcntlogin;
}
?>
<?php
if ($zcntlogin) {
$id = "true";
$db = mysql_connect("localhost", "foo")or exit("Could not connect");
$db1 = mysql_select_db("report",$db);
?>
<FORM>
<TABLE WIDTH=800>
<TR>
<TD ALIGN="CENTER" COLSPAN=8><FONT SIZE=+2><B>Report
Summary</B></FONT></TD>
</TR>
</TABLE>
<?php
$query2="select * from report WHERE users REGEXP '$zcntlogin'";
echo $query2;
$result2 = mysql_query($query2) or die(mysql_error());
for ($i = 0; $i <
mysql_num_fields($result2); $i++) {
?>
<?php
if (($myrow2)){
$myrow2["file1"] = preg_replace("/\s/", "%20" ,
$myrow2["file1"]);
$records+=1;
?>
<TABLE>
<TR>
<TD COLSPAN=4><sb><sb> <?php echo ($myrow2["file1"]) ?
$myrow2["file1"] :"" ; ?><sb>
<A HREF="../uploads/<?php echo $myrow2["file1"];
?>">[expand]</A></TD>
</TR>
</TABLE>
<?php
}
?>
<?php
$myrow2=mysql_fetch_array($result2);
}
?>
<TABLE>
<TD COLSPAN=4>Total Number of Records:<sb><sb> <?php echo $records ;
?><sb>
<TR>
<TD COLSPAN=128><HR></TD>
</TR>
</TABLE>
<?php
mysql_close($db);
}
?>
------------------------------------------------------
------------------------------------------------------------------------
[2002-07-05 10:36:57] r.denis@bell.ca
How hard is to write the following.
echo $query2;
It does not take a brain to figure out that both queries are
identical.
I suspect that the issue might be in one of the php regex*.h files.
/usr/local/include/php/ext/mbstring/mbregex.h
/usr/local/include/php/main/php_regex.h
/usr/local/include/php/regex
/usr/local/include/php/regex/cclass.h
/usr/local/include/php/regex/cname.h
/usr/local/include/php/regex/regex.h
/usr/local/include/php/regex/regex2.h
/usr/local/include/php/regex/regex_extra.h
/usr/local/include/php/regex/utils.h
There is nothing wrong with the query.
I do not have to addslashes ie \"$zcntlogin\";
or should not have to add % to the query variable.
To further clarify the issue. The query returns records,
however it does not return all of the records of the given
userid zcntlogin.
Userids in this context is a list of space delineated userids. Which
is used to grant access to specific files.
RLIKE should work however it does not.
------------------------------------------------------------------------
[2002-07-05 10:18:09] sander@php.net
You're very likely to be messing up with quotation and/or other special
characters. Print $query2 before sending it mysql to see what you're
doing wrong.
Not a bug in PHP. For more, ask support on the appropriate places (see
http://php.net/support for a list).
------------------------------------------------------------------------
[2002-07-05 09:57:11] r.denis@bell.ca
# locate php.ini
/usr/local/etc/php.ini
/usr/local/etc/php.ini-dist
ruoc4k# grep -i register /usr/local/etc/php.ini
; This directive describes the order in which PHP registers GET, POST,
Cookie,
; Whether or not to register the EGPCS variables as global variables.
You may
; register_globals to be on; Using form variables as globals can
easily lead
register_globals = on
register_argc_argv = On
; autoregister constants of a components typlib on com_load()
;com.autoregister_typelib = true
; register constants casesensitive
;com.autoregister_casesensitive = false
;com.autoregister_verbose = true
Register locals was turned on because of the way some of the data was
being passed.
------------------------------------------------------------------------
[2002-07-05 03:55:10] mfischer@php.net
In PHP 4.2.0, the 'register_globals' setting default changed to
be off. See http://www.php.net/release_4_2_0.php
for more info.
We are sorry about the inconvenience, but this change was a necessary
part of our efforts to make PHP scripting more secure and portable.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/18172
--
Edit this bug report at http://bugs.php.net/?id=18172&edit=1