Jump to content

Recommended Posts

Well here is my php code, yes it has tabs so it will mess up here but the code is fine, the bottom regexp replacements for the url both work, its the top eight that return errors.

 

Submitting Message...

[center] Testing [/center]

Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash
Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash
Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash
Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash
Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash
Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash
Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash

 

Please tell me what is wrong.

 

	echo "Submitting Message...<br />" . $_POST['message'];
$_POST['message'] = htmlspecialchars($_POST['message']);

############################################################

$_POST['message'] = preg_replace("\[b\](.+?)\[\/b\]",
	" <strong>$1</strong>", $_POST['message']);

$_POST['message'] = preg_replace("\[i\](.+?)\[\/i\]",
	" <em>$1</em>", $_POST['message']);

$_POST['message'] = preg_replace("\[u\](.+?)\[\/u\]",
	" <u>$1</u>", $_POST['message']);

############################################################

$_POST['message'] = preg_replace("\[img\](.+?)\[\/img\]",
	" <img alt=\"$1\" src=\"$1\" />", $_POST['message']);

############################################################

$_POST['message'] = preg_replace("\[left\](.+?)\[\/left\]",
	" <div align=\"left\">$1</div>", $_POST['message']);

$_POST['message'] = preg_replace("\[center\](.+?)\[\/center\]",
	" <div align=\"center\">$1</div>", $_POST['message']);

$_POST['message'] = preg_replace("\[right\](.+?)\[\/right\]",
	" <div align=\"right\">$1</div>", $_POST['message']);

############################################################

$_POST['message'] = preg_replace("/([a-zA-Z]+:\/\/[a-z0-9\_\.\-]+".
	"[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%\=\,\.]+)/",
	" <a href=\"$1\" target=\"_blank\">$1</a>", $_POST['message']);

$_POST['message'] = preg_replace("/[^a-z]+[^:\/\/](www\.".
	"[^\.]+[\w][\.|\/][a-zA-Z0-9\/\*\-\?\&\%\=\,\.]+)/",
	" <a href=\"http://$1\" target=\"_blank\">$1</a>", $_POST['message']);

############################################################

$_POST['message'] = trim(addslashes($_POST['message']));

this is a pattern error, enclose all of your patterns with "/ -pattern- /" and make sure to escape any / (forward slashes) in your pattern.

 

 

eg:

	$_POST['message'] = preg_replace("/\[b\](.+?)\[\/b\]/",
	" <strong>$1</strong>", $_POST['message']);

$_POST['message'] = preg_replace("/\[i\](.+?)\[\/i\]/",
	" <em>$1</em>", $_POST['message']);

$_POST['message'] = preg_replace("/\[u\](.+?)\[\/u\]/",
	" <u>$1</u>", $_POST['message']);

 

hope this helps,

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.