Warning: Preg_replace() [function.preg-replace]: Unknown Modifier
Warning: preg_replace() [function.preg-replace]: Unknown modifier 'a' in index.php on line 6
my code as following;
<?php //line 1
$str=' test & me '
$p='^[^a-z]+$'
$r='_'
$str=preg_replace($p, $r, $str); // here is line 6
echo $str;
?>
View Complete Forum Thread with Replies
Related Forum Messages:
Warning: Preg_replace() [function.preg-replace]: No Ending Delimiter '~' Found
Warning: preg_replace() [function.preg-replace]: No ending delimiter '~' found in /home/.marble/ryannaddy/iconnect.publicsize.com/functions.php on line 17 Can someone help me find the ending delimiter <?php $txtArr = array( '~a~','~b~','~c~','~d~','~e~','~f~','~g~','~h~','~i~','~j~','~k~','~l~','~m~','~n~','~o~','~p~','~q~','~r~','~s~','~t~','~u~','~v~','~w~','~x~','~y~','~z~', '~A~','~B~','~C~','~D~','~E~','~F~','~G~','~H~','~I~','~J~','~K~','~L~','~M~','~N~','~O~','~P~','~Q~','~R~','~S~','~T~','~U~','~V~','~W~','~X~','~Y~','~Z~', '~1~','~2~','~3~','~4~','~5~','~6~','~7~','~8~','~9~','~0~', '~`~','~~~','~!~','~@~','~#~','~$~','~\%~','~^~','~&~','~*~','~(~','~)~','~-~','~\_~','~=~','~+~','~[~','~]~','~~','~{~','~}~','~|~','~;~','~'~','~:~','~"~','~,~','~.~','~/~','~<~','~>~','~?~','~ ~' ); ?>
View Replies !
Preg_replace() [function.preg-replace]
i made a code for my forum does bbcode. Ive designed it so that me, the admin can input a template, such as if i wanted the template would be a ":" and then a ")" one after another, then a function checks the post when you go to view it and see whether it has a template in it, if it doesnt it leaves it and if it does the function replaces the template with a replacment, which is also designated by the admin and stored in a database. Code:
View Replies !
Warning: Preg_match(): Unknown Modifier
PHP Code: foreach ($text as $key){ //line 48 $matched = preg_match('.*(pictureit(.*))+', $text[key($text)]); //line 49 print_r ($matched); //line 50 next($text); //line 51 } // line 52 I know that $text[key($text)] is the same thing as $key in this case. Code: Warning: preg_match(): Unknown modifier '*' in C:pearbcode.php on line 49 i was reading about backslacshes and spaces cant be in my string or something. this is my first time with delimters, so im try to figure out why this isnt working cause i did a tutorial , bahhh .
View Replies !
A Function In Preg Replace, Works?
I'll use a function (crearvinculo()) in a preg_replace, but the functon doesn't get the variable. Here's the code: $txt = preg_replace("/[enlaceGrupo¦(.*?)]/", crearvinculo('1'),$txt); I've tried to use the "e" and 1, like the manual in php.net, and 1, $1.. Nothing works, and the variant with de "e" and 1 give's me an php error.
View Replies !
Mail() Function - Warning: Unknown Error
I have been getting the crap beat out of me by the mail function. It just wont send the mail. I have even tried this simple test: if (mail('myrealaddress@yahoo.com','Getting this to work','what the hell is it going to take?')) The result - Warning: Unknown error in c:phpdev5wwwalaskaerrandsindex.php on line 135 And when I say myrealaddress I mean I really used a valid email address. I know that the mail function just isn't working for me and it has to do with something other than my code.
View Replies !
Preg_replace With E Modifier
I'd like to use something like preg_replace("...","$this->somefunction('1','2');", $content); It says "Cannot find function somefunction()" I tried some escaping, but didn't work. Any ideas?
View Replies !
Preg_replace Function To Remove And Replace
i have this variables: $url = '/products/computers/_es/' $pat = '/(_[a-zA-Z]{2})/' $rep = '' i need to get rid of the '_xx/' part. with that $pat pattern, a preg_replace $pat,$rep,$url) returns '/products/computers//' and worst, if the $url changes to '/products/_es/computers/' it returns '/products//computers/' while it should'nt to ANYTHING at all. the preg_replace must only work when the _XX/ is at the end of the $url.
View Replies !
Warning: Preg_match() [function.preg-match]: Compilation Failed: Unmatched Parentheses
I'm making a newsletter script, this problem is beyond me. The error is: Warning: preg_match() [function.preg-match]: Compilation failed: unmatched parentheses at offset 123 in /newsletter.php on line 16 Line 16 - if(preg_match('/A(?:[a-zA-Z0-9]!#$%&'*+/=?^_`{|}~-])+(?:.[a-zA-Z0-9]!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-z0-9])?.))+(?:[a-zA-Z]{2}|com|org|net)/i',$email)) return true;
View Replies !
Preg_match - Warning: Preg_match() [function.preg-match]: Delimiter Must Not Be Alphanumeric Or Backslash.
I am trying to match this this line 8f89c2f9-6939-4bff-b800-a6f46e2d0f24 it is a random number everypage load the full string is this MyToken=8f89c2f9-6939-4bff-b800-a6f46e2d0f24 I am connecting to the page with curl so the code is curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); $page = curl_exec($ch); preg_match('MyToken=([0-9a-f-]*)', $page, $mytoken, PREG_OFFSET_CAPTURE, 3); echo $mytoken; echo $page; curl_close($ch); but it keeps giving me an error Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash.
View Replies !
Warning: Ftp_exec() [function.ftp-exec]: SITE EXEC Is An Unknown Extension
This is kind of a part II to a question a posted earlier about exec and shell_exec not working. I'm trying to use ftp_exec to execute some simple command: $conn_id = ftp_connect("$server") or die ("Cannot initiate connection to host"); ftp_login($conn_id, "$username", "$userpass") or die("Cannot login"); $command = 'cd..' if (ftp_exec($conn_id, $command)) { echo "$command executed successfully"; } else { echo "could not execute $command"; } ftp_close($conn_id); I'm getting the following error: Warning: ftp_exec() [function.ftp-exec]: SITE EXEC is an unknown extension in /home/urieilam/public_html/work/video/test1.1.php on line 21 could not execute cd.. Have tried other commands as well, get the same. Could this be a security issue or something to do with p Safe Mode? I don't know much about commands, shell, etc..
View Replies !
Ereg Replace Or Preg Replace
I have HTML content that I want to do a search and replace of urls. If the content contains an <a href="" I want it to take the content and append an id to the end. For example: <p>content here <a href="http://www.somewhere.com/">link</a></p> would change to: <p>content here <a href="http://www.somewhere.com/?id=100">link</a></p> and <p>content here <a href="http://www.somewhere.com/?var=1">link</a></p> would change to: <p>content here <a href="http://www.somewhere.com/?var=1&id=100">link</a></p> Basically I just want to search for hrefs and add a tracking on the end.
View Replies !
Preg Replace - @ Sign In Replace
$string = preg_replace('/m[^a-z]*y[^a-z]*s[^a-z]*p[^a-z]*a[^a-z]*c[^a-z]*e/i', 'test', $string); //this filters out the work myspace with any thing in between the letters I want to //modify it to also match when a user uses the @ sign in replace of the a in myspace.
View Replies !
Preg Replace
I want [color=f35f46]lol[/color] to change to <span style="color: #f35f46">lol</span> with php preg_replace.
View Replies !
Simple Preg Replace
I would like to know how I would go about changing my links throughout a document using preg_replace. For example. I have links called foo.php throughout my document I want to change it to new.php how would I go about doing this using preg_replace and prevent myself from typing it manually throughout the document. I have looked at php manual but it doesnt say how to do it throughout a document and not specific a named variable.
View Replies !
Preg Replace And URLs
Hi, I'm having some problems with my URL-code, which automatically turns adressess into urls. Problems is that when people type "something.something else" that's also turned into an url. So what I'd like to do is change the below expression to only turn it into urls when you type either "www" in front (www.google.com) or when you use "http://" (http://google.com,http://www.google.com). $text_s = preg_replace("/(?<=^¦s)((https?¦ftps?)://)?(([-_a-zA-Z0-9]+.)+)([a-zA-Z0-9]{2,6})(/[^][s]*)?(?=s¦$)/e","'$1'!=''? '<a href="$1$3$5$6" target="_blank">$1$3$5$6</a>':'<a href="http://$3$5$6" target="_blank">$3$5$6</a>'",$text_s);
View Replies !
Trim Preg Replace...
im using: if($varCheck && trim(preg_replace("/[a-zA-Z0-9,@._]+/", "", $varCheck))) $stop = true; if($stop=="true") { blah } how would i go abouts adding "-" ( a hyphen, -) to preg replace?
View Replies !
Preg Replace Beginning
I have a filename such as admin_press.php. I want to do a preg_replace so that I end up with just "press". I can get it to remove "admin_" or ".php", but never together. How would I go about doing that? This is what I was hoping would work, but it removes everything. preg_replace("/^admin_.*?.php$/", "", $file)
View Replies !
Preg Replace With Variables
I have a loop that loops through and sets $q to certian tags in an HTML documet such as body UL etc etc. It also sets $a to a list of styles for that tag. There are no <> in the $q variable. What I need to do is for each loop is change. <BODY> into <BODY style="color: #000000;" > etc etc I was going to do for each loop something like $templatein = preg_replace('/<$q/','<$q style="$a"',$templatein); just can't seem to get it to work. Should be pretty str8 forward. I'm just new to PCRE.
View Replies !
Preg Replace Problem
I want to replace all character other then alphanumeric to "-", to get this output i ote this expression but it not works, please check it. preg_replace([^a-zA-Z0-9],"-",$string);
View Replies !
Regexp/preg Replace
Im trying to run a preg_replace for replacing some things in the contents of a retrieved webpage. For example, im using the snip below to strip out all javascripts within the content preg_replace("/<script[^>]*?>.*</script*>/is", "", $content); The problem with dat however is that, if there happens to be more than 2 script tags within the content, e.g, <script> some js codes </script> some content here, this should be omited <script> another js codes </script> the match matches from the begining script to the end script, swallowing allong "some content here". The idea is to simply replace contents within each individual script tags.
View Replies !
Preg Replace :: Strip Out
I use code like this to strip things out PHP Code: $string = preg_replace('#</?t(able|r|d)(s[^>]*)?>#i', '', $string);Â Â // strip out tables But I need to strip out this: left:0px; top: 0px;
View Replies !
Preg Replace Newlines
I have a form box where users enter in directions (one per line). I then turn each line into a list item <li>. The problem is that when people enter a blank line at the end it creates a new list item. So I tried the following preg_replace to strip out extra lines at the end of the string. $directions = preg_replace('/ +$/','',$_POST['directions']);
View Replies !
Using Variables In Preg Replace
I need to replace a chunk of html code in 100 odd pages for a project. So I have written a php script that opens the files, does a preg_replace to cut the code I don't want then save the file (and loop over the rest). However, I am having trouble with the preg_replace. This works: $new_contents = preg_replace ("/$replace1(.*)</td>/", "cut out", $contents); Where $replace1 is the beginning part of the html I want to cut. But, I want to specify the second part and not just use </td>. So I thought it would be: $new_contents = preg_replace ("/$replace1(.*)$replace2/", "cut out", $contents); But this doesn't work. Could someone check my syntax, please? Or is it even possible to have two variables in the expression?
View Replies !
Preg Replace For Href Links
Can someone please give me an example of how i can use preg_replace for a link such as: <?php echo"<a href="make.php?id=$id&modelname=$name">$name</a>"; ?> to be changed to.. <?php echo"<a href="make/$name-$id.html">$name</a>"; ?>
View Replies !
New Line /r/n Preg Replace Problem -> <br>
I’m having a real bit of trouble, and I cant narrow it down. I’m trying to get a form to post a message to a mySQL data base, and replace the users input new lines into - But this doesn’t seem to be working as expected. - I have tried lots of things, but they all give strange results. - the Mysql column is a text column - I have tried using nl2br, but this does nothing to the text. Im currently using: function nl2br2($string) { $string = str_replace(' ', '<br>', $string); $string = str_replace(' ', '<br>', $string); $string = str_replace(' ', '', $string); return $string; This works perfect, unless the new line start with an n, if the new line starts with an n the n gets striped: first line new line third gets converted to first line ew line third if I use this: Code:
View Replies !
Bolding Keywords With Preg Replace
Im setting up a search engine for a content site. It works find, but i still need the keywords to be BOLD on the search results. For example, if i search for "dog" and one of the results is: * Dog contest winner Last friday an Akita dog won the dog contest... The result SHOULD come up as: * Dog contest winner Last friday an Akita (STRONG)dog(/STRONG) won the dog contest... --I dont quite get the reg.expressions... but i know that this could be accomplished with preg_replace.
View Replies !
Preg Replace MySql Query
I curently use SELECT * FROM table WHERE REPLACE(name,' ','-')='$name' but would like to also replace periods commas undersores etc with out lots of REPLACE(REPLACE(REPLACE.
View Replies !
Preg Replace :: Strip BB Brackets Out Of The String
Im having some troubles getting a function I've written to return the correct information. PHP Code: function strip_bb_code($str) { Â Â Â Â $find = '/[(.*)](.*?)[(.*)]/is' Â Â Â Â Â Â Â Â Â Â Â Â $replace = '$2' Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return preg_replace($find, $replace, $str); Â Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â $string = '[test]test 1[/test] [yeah]yeah[/yeah]' Â Â Â Â Â Â Â Â print strip_bb_code($string); This function is supposed to strip any BB Brackets out of the string, and return only the text. For the example above, this should print "test1yeah". It is only printing "yeah" Where have I gone wrong?
View Replies !
Preg Replace Thows An Unexpected T Variable Error
I'm drawing some pre-HTML formatted content from a DB table. The result set that resides in a $content VAR looks something like this: <h1>Crew Member Applicant</h1> <h2>Personal Information Section</h2> <p>Blah, blah, blah...</p> On a few pages of this application, I need to slip a position name just after the Crew Member Application line so it'll look something like this: "Crew Member Application - Captain". Code:
View Replies !
Warning: Unknown():
Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 What does it mean? how can I fix it?
View Replies !
Please Help With This Error: Warning: Unknown(): A Session Is Active.
I've searched high and low for this on the net but stil haven't found an answer. I'm trying to install both postnuke and xoops on a win2k server with php 4.3.3. and mysql installed. Both applications are loading terribly slow. When the page finally has been rendered I got the following error: Warning: Unknown(): A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0 Is it a bug in PHP? Has it something to do with the fact that I'm running it at win2k? Since I think it has something to do with sessions, I attach a snapshot of the results for phpinfo() Directive Local Value Master Value session.auto_start Off Off session.bug_compat_42 On On session.bug_compat_warn On On session.cache_expire 180 180 session.cache_limiter nocache nocache session.cookie_domain no value no value session.cookie_lifetime 0 0 session.cookie_path / / session.cookie_secure Off Off session.entropy_file no value no value session.entropy_length 0 0 session.gc_divisor 100 100 session.gc_maxlifetime 1440 1440 session.gc_probability 1 1 session.name PHPSESSID PHPSESSID session.referer_check no value no value session.save_handler files files session.save_path D:programfilesphpsessiondata D:programfilesphpsessiondata session.serialize_handler php php session.use_cookies On On session.use_only_cookies Off Off session.use_trans_sid Off Off
View Replies !
PHP Warning: Module 'gd' Already Loaded In Unknown On Line 0
when ever i am running pear i am getting this warning message : ---- PHP Warning: Module 'gd' already loaded in Unknown on line 0 Warning: Module 'gd' already loaded in Unknown on line 0 PHP Warning: PHP Startup: pdf: Unable to initialize module Module compiled with module API=20060613, debug=0, thread-safety=0 PHP compiled with module API=20050922, debug=0, thread-safety=0 These options need to match
View Replies !
Replace Or Preg_Replace
I want to change a single line in a text file, so I have: $find="<loc>http://mydomain.com/myfile.php</loc> <lastmod>2006-01-01</lastmod>"; $replace="<loc>http://mydomain.com/myfile.php</loc> <lastmod>2007-01-01</lastmod>"; Then: $result = str_replace($find, $replace, $file); I need line breaks because I have to change the date in the second line, depending on the filename in the first line. It's on a Windows machine, so the newline works fine. BUT - I don't know the date in $find. I really need something like $find="<loc>http://mydomain.com/myfile.php</loc> <lastmod>****-**-**</lastmod>"; wildcards..! but that isn't available. And I can't see how preg_replace would work here.
View Replies !
Use Preg_replace To Replace
I am just trying to use preg_replace to replace /films/blah/blah with http://www.example.com/films/blah/blah So I can just replace the films/ bit yeah? I have tried so hard to work it out but it has beaten me. I am sure many of you will know it straight away and save my time.
View Replies !
Preg_replace End Replace
This is the code I use: Code: $parameter = explode(",", $lines[$i], 20); $format = $parameter; $tmp = explode("},{", $parameter[19]); // Replacements $replace[0] = ""; $replace[1] = ""; $pattern[0] = "/{/"; $pattern[1] = "/},/"; $patternx[0] = "/,{/"; $patternx[1] = "/},/"; $patterns[0] = "/,{/"; $patterns[1] = "/}"; $format[19] = trim(preg_replace($pattern, $replace, $tmp[0],1)); $format[20] = trim(preg_replace($patternx, $replace, $tmp[1],1)); $format[21] = trim(preg_replace($patterns, $replace, $tmp[2],1)); What I want to know is how do I check for the last } in a text? For instant, I wanna replace ,{Hi, {Name}},{How's {Job} {Time}},{You Doing {Name}} to remove the { } for the beginning and end of it so it'll be: ,Hi, {Name},How's {Job} {Time},You Doing {Name}.
View Replies !
Warning: Unknown(): Your Script Possibly Relies On A Session
I'm getting a strange error in one of my programs: Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 Funny thing is I'm not using any globals at all in my script, but I am using $_SESSION. I even did grep GLOBAL *.php in my directory in case it's in one of the functions I included and nothin'. Strangely the error is output at the very end of the code (after a simple print statement which is before the closing php tag). I don't see the point in messing with register_globals when I don't use globals so am hoping for another solution. Any ideas?
View Replies !
Warning : Unknown(): Unable To Load Dynamic Library
I install php 4.3.1 on Windows XP (Use Apache 2.0.44) I open c:windowsphp.ini and uncomment line extension=php_gd2.dll When I restart Apache It has error pop up every time I open php file in browser like this: Warning : Unknown(): Unable to load dynamic library './php_gd2.dll' - The specified module could not be found.
View Replies !
Warning: Unknown: 1 Result Set(s) Not Freed. Use Mysql_free_result To Free ...
Anyone seen this error before? Warning: Unknown: 1 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0 Not certain how / where it would find another result set. Been reading up on the mysql_free_result command; when/where would it be utilized? Here is my scenario. I have a dynamic form that stores, draws data, edits records and emails data. There are two main sections of the site: Submission and Revision. I assume it's best to free results when a user logs out of their account; while logged, the user can proceed to make revisions. I'm afraid they will run into the same problem I'm experiencing now. Can the results be freed without causing the user to lose their work?
View Replies !
PHP Warning: Unknown(): Unable To Load Dynamic Library
I'm running a dedicated server with windows 2003 server with IIS, anyway recently a strange message started to pop out in my face each time I tried to access a page have query to the database. --------------- PHP Warning: Unknown(): Unable to load dynamic library 'E:Program FilesSWsoftPleskAdditionalPhpextensionsphp_curl.dll' - Access is denied. in Unknown on line 0 -------------------
View Replies !
Preg_replace - Replace Something With An Anchor Tag
I dont think I'll ever understand regular expressions ... I need to do th efollowing and I just don't know where to start: $haystack = "How much wood would a wood chuck chuck if a woodchuck could chuck wood?"; $needles = ("wood","chuck","wood chuck"); I want to replace every needle with an anchor tag like this: <a href="def.html?word=wood">wood</a> <a href="def.html?word=chuck">chuck</a> <a href="def.html?word=wood%20chuck">wood chuck</a> How do I do this?
View Replies !
Search And Replace In Preg_replace
Im trying to figure out how to search replace the var in a preg_replaceThis is the basic code: $search = array( '#[item](.+?)[/item]#mis', ); $replace = array( '<a href="page.php?item=$1">$1</a>',); $link = preg_replace ( $search, $replace, $link ); However if the 'item' has apostrophe in the '$1' I want that replaced as well. Anyone have ideas on how to do that?
View Replies !
Preg_replace() Replace Characters
I want to replace all of the ^M chacters with characters. This string came from fgetc() 'ing a binary file until the feof(). I've tried: preg_replace("^M", "", $line); preg_replace("^M", "", $line); preg_replace("/^M/", "", $line); The only one that doesn't complain is the third one, but it doesn't work, it just fails.
View Replies !
Preg_replace With A " As Replace
Am trying to turn an HTML file into a string (will use file_get_contents()), and then turn all of the "s into "s so that I can echo the string. Having problems with what to put in the pattern and what t put in replace I have: $file = file_get_contents("file.html"); $pattern = """; $replacement = """; echo preg_replace($pattern, $replacement, $file); I don't get an output at all, anyone tell me *** i'm doing wrong?
View Replies !
Warning: Unknown(): Failed To Write Session Data (files)
When I run this: <?PHP session_start(); echo session_id(); ?> It give me the right ouput but it also gives me a huge error message: Warning: session_start(): open(/tmpsess_c6782a171d1c85b13e9b9d3ff4c4a88a, O_RDWR) failed: No such file or directory (2) in C:Program FilesApache GroupApache2htdocs10.1.php on line 2 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:Program FilesApache GroupApache2htdocs10.1.php:2) in C:Program FilesApache GroupApache2htdocs10.1.php on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:Program FilesApache GroupApache2htdocs10.1.php:2) in C:Program FilesApache GroupApache2htdocs10.1.php on line 2 c6782a171d1c85b13e9b9d3ff4c4a88a Warning: Unknown(): open(/tmpsess_c6782a171d1c85b13e9b9d3ff4c4a88a, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 What am I doing wrong?
View Replies !
|