deliminator question

Hello all, I had a question that I hope you guys can help with. I am a bit stuck trying to get the deliminator working on this line of code.

[php]if(preg_match($ext."$", $upfile_name))[/php]

I have tried many variations that I thought would work but no luck so far. Any suggestions?

For further reference, the code snippet I am working through is this:

[php] $sql = “SELECT * FROM “.$this->prefix.”_uploads WHERE type = ‘banned’”;
$res = $this->db->sql_query($sql, FALSE);
if($this->db->sql_numrows($res) != 0) {
$p = 1;
while($row = $this->db->sql_fetchrow($res)) {
$ext = $row[‘info’];
if($this->howtoban == 0) {
if($ext != “[NOEXT]”) {
if(preg_match($ext."$", $upfile_name)) {
$o = 1;
echo “

”.MYU_SORRYCANNOTUP."";
}
} else {
if(!preg_match("#…+$#", $upfile_name)) {
$o = 1;
echo “”.MYU_SORRYCANNOTUP."";
}
}
} elseif($this->howtoban == 1) {
if($p != 0) {
if($ext != “[NOEXT]”) {
if(preg_match($ext."#$#", $upfile_name)) {
$o = 0;
$p = 0;
$e = 0;
} else {
$o = 1;
$e = 1;
}
} else {
if(!preg_match("#…+$#", $upfile_name)) {
$o = 0;
$p = 0;
$e = 0;
} else {
$o = 1;
$e = 1;
}
}
}
}
}[/php]

As you can see, I got other deliminators already in place and it’s just that one from the post above that is eluding me ATM.

anyone?

Have you tried adding the ## signs to the outside of the delimiter just like your others.

yes, the problem seems to lie like this.

in this section of coding,
[php] while($row = $this->db->sql_fetchrow($res)) {
$ext = $row[‘info’];
if($this->howtoban == 0) {
if($ext != “[NOEXT]”) {
if(preg_match($ext."$", $upfile_name)) {
$o = 1;
echo “

”.MYU_SORRYCANNOTUP."";
}
} else {
if(!preg_match("#…+$#", $upfile_name)) {
$o = 1;
echo “”.MYU_SORRYCANNOTUP."";
}
}[/php]

you can see I already added the deliminator to the

[php if(!preg_match("#…+$#", $upfile_name)) {[/php]

I also have done it here:

[php] $ext = $row[‘info’];
if($this->howtoban == 0) {
if($ext != “[NOEXT]”) {
if(preg_match($ext."#$#", $upfile_name)) {[/php]

which is not shown in the first post because I pulled it from a eariler file. But the problem seems to lye in this section.

[php]if(preg_match($ext."#$#", $upfile_name)) {[/php]

I keep getting a error saying it needs a deliminator. so I figured it has something to do with the $ext. before the “#$#”, which I have tried different thing like adding a deliminator to the

[php] $ext = $row[‘info’];[/php]

Seem’s everything I try just fails and says it needs a deliminator on that line

[php]if(preg_match($ext."#$#", $upfile_name)) {[/php]

I don’t know if that makes any sense to anyone.

Can you echo or print_r the $ext variable that may yield some more clues or results.

not following. sorry.

Try this
[php] if(preg_match("$".$ext, $upfile_name)) {
[/php]

Nope, it said it was missing a closing deliminator. Then, after I added the deliminator. I was getting these errors.

[14-Jul-2012 00:22:40 UTC] PHP Warning: preg_match(): Unknown modifier 'p' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:40 UTC] PHP Warning: preg_match(): Unknown modifier 'c' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:40 UTC] PHP Warning: preg_match(): Unknown modifier 'p' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:40 UTC] PHP Warning: preg_match(): Unknown modifier 'a' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:40 UTC] PHP Warning: preg_match(): Unknown modifier 'h' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:40 UTC] PHP Warning: preg_match(): Unknown modifier 'c' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:40 UTC] PHP Warning: preg_match(): Unknown modifier 'h' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:40 UTC] PHP Warning: preg_match(): Unknown modifier 'b' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:40 UTC] PHP Warning: preg_match(): Unknown modifier 'c' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:40 UTC] PHP Warning: preg_match(): Unknown modifier 'n' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:58 UTC] PHP Warning: preg_match(): Unknown modifier 'p' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:58 UTC] PHP Warning: preg_match(): Unknown modifier 'c' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:58 UTC] PHP Warning: preg_match(): Unknown modifier 'p' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:58 UTC] PHP Warning: preg_match(): Unknown modifier 'a' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:58 UTC] PHP Warning: preg_match(): Unknown modifier 'h' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:58 UTC] PHP Warning: preg_match(): Unknown modifier 'c' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:58 UTC] PHP Warning: preg_match(): Unknown modifier 'h' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:58 UTC] PHP Warning: preg_match(): Unknown modifier 'b' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:58 UTC] PHP Warning: preg_match(): Unknown modifier 'c' in /public_html/modules/Uploads/index.php on line 205 [14-Jul-2012 00:22:58 UTC] PHP Warning: preg_match(): Unknown modifier 'n' in /public_html/modules/Uploads/index.php on line 205

whats line 205?

Line 205 is the line you had me change, which since that, I put it back to how it was.

[code]

<a HREF="#"
onMouseOver=“alert(‘DONT FORGET TO CLICK SUBMIT WHEN YOUR DONE EDITING YOUR PROFILE!’)”;>CLICK SUBMIT   [/code]

whoops, that was a different code for something else., I just dont see a edit button so I have to make a new post. But line 205 is this line.

                                                            if(preg_match($ext."#$#", $upfile_name)) {

try removing the #s from that line the line without them does not appear to be an issue then.

I have done it with out the # and it comes back with an error of no ending deliminator on that line, “Line 205”.

Overall, my goal is to get this php5.3 compliant. The script worked before, just trying to end the errors that come up in the log. I changed over all the ergie to the preg_match, and now its the deliminator that is giving the problem.

Whatever your trying to pass to preg_match() apparently contains a / you will need to escape it.

I finally got back to it and was able to get it fixed. I figured I would post the fix. The issue was this:

[php]if(preg_match($ext."$", $upfile_name))[/php]

Putting the deliminator where the $ so it would look like

[php]if(preg_match($ext."/$/", $upfile_name))[/php]

just was not working. So what I found to work was to do this

[php]if(preg_match("/".$ext."$/", $upfile_name)) {[/php]

and it solved my issues. Thanks for the assistance. It was appreciated.

Sponsor our Newsletter | Privacy Policy | Terms of Service