Jump to content

Recommended Posts

I get the error -

[code]Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /home/gamesm/public_html/freeforums/suspend.php on line 26[/code]

Lines 21 - 26 go like this -

[code]21  $settingscontent = file_get_contents($settingsdir);
22
23  $mode[0] = "$maintenance = 0;";
24  $newmode[0] = "$maintenance = 2;";
25
26  $newsettingscontent = preg_replace($mode, $newmode, $settingscontent);[/code]

Any idea where I am going wrong??  Its stopping my script from working...

Will
I think you need a \ before the $ in your mode strings
[code]
23  $mode[0] = "\$maintenance = 0;";
24  $newmode[0] = "\$maintenance = 2;";
[/code]

If you want to change the actual text "$maintenance" not the variable value of $maintenance

Also, since you are not using any reg expressions, it's best to use str_replace() because it runs faster and uses less resources.
try:

[code]21  $settingscontent = file_get_contents($settingsdir);
22
23  $mode[0] = "/\$maintenance = 0;/";
24  $newmode[0] = "\$maintenance = 2;";
25
26  $newsettingscontent = preg_replace($mode, $newmode, $settingscontent);[/code]

you need to quote special regular expression characters, see: http://au3.php.net/manual/en/function.preg-quote.php
in your suspend.php

when you echo the $newsettingscontent, is it the correct string?

I notice you have the function file_put_contents_php4 () but you are not calling it anywhere in the script, so the file won't be edited.

Let me know if this solves the problem.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.