Forum Moderators: coopster

Message Too Old, No Replies

preg_replace problem

changing '&' to '&'

         

ahmedtheking

4:44 pm on Jan 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, so after looking at this post (www.webmasterworld.com/forum10/7499.htm) about why W3C validator doesn't like '&' in the url, i decided to use php to clean out all the '&' in my urls and change them to '&'. This is my perg_replace script:

$Row2[link] = "table=packages&package=starter";

preg_replace("&","&",$Row2[link]);

Note: $Row2[link] is being pulled out of a database!

The error i get is:

Warning: No ending delimiter '&' found in /home/aliashos/public_html/index.php on line 220

Netizen

7:58 pm on Jan 9, 2005 (gmt 0)

10+ Year Member



Take a look at the syntax for preg_replace [php.net]. The line should be

$Row2['link']=preg_replace("/&/","&",$Row2['link']);

(You should also quote array keys otherwise they could be references to constants)