Bug #18172 Updated: Mysql_query function RLIKE and REGEXP
| From: | sander@php.net | Date: | Fri, 05 Jul 2002 17:46:04 +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-13242@lists.php.net to get a copy of this message | ||
ID: 18172
Updated by: sander@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:
What does mysql_error() say about this query? Just call echo
mysql_error() directly after the mysql_query() call.
Previous Comments:
------------------------------------------------------------------------
[2002-07-05 13:42:18] r.denis@bell.ca
# strings /usr/local/libexec/apache/libphp4.so | grep -i like
Call-time pass-by-reference has been deprecated - argument passed by
value; If you would like to pass it by reference, modify the
declaration of %s(). If you would like to enable call-time
pass-by-reference, you can set allow_call_time_pass_reference to true
in your INI file.
I tried for the fun of it to see whether or not the above had any
bearing....appears not.
------------------------------------------------------------------------
[2002-07-05 13:22:19] r.denis@bell.ca
$query2="select * from report WHERE users REGEXP 'robert.denis'";
$query2="select * from report WHERE users RLIKE '%robert.denis'";
$query2="select * from report WHERE users RLIKE '%robert.denis%'";
Does not return everything containing "robert.denis"
//or $zcntlogin
4.5-RELEASE FreeBSD 4.5-RELEASE #0: Mon Jan 28 14:31:56 GMT 2002
murray@builder.freebsdmall.com:/usr/src/sys/compile/GENERIC i386
------------------------------------------------------------------------
[2002-07-05 13:12:53] sniper@php.net
Make a SHORT example where you don't use any variables
but the exact same SQL line you tried with the mysql shell.
------------------------------------------------------------------------
[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.
------------------------------------------------------------------------
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