Jump to content

Replacing HTML spaces


Ziph

Recommended Posts

Hello

 

I put a filelink + filename in my database that contains spaces

i want to remove those with this php script.

 

I send the filelink from the the previous page to this one with a header sending the filename with it in a $msg=

 

$filename = $_GET["msg"];

 

$filelinkconstruct = mysql_query("SELECT filelink FROM uploads WHERE username='$username' AND filename='$filename' ");

while($fix = mysql_fetch_assoc($filelinkconstruct)) {

$mustfixlink = $fix['filelink'];

};

 

$fixedlink = preg_replace('[([\r\n])[\s]+]', '_', $mustfixlink);    /// it wont replace the whitespaces with _ i tried a lot of diffrent space codes but for some reason it wont work

 

echo "$fixedlink = fixedlink";

echo "$mustfixlink = mustfixlink";

 

EXAMPLE: http://www.gosuhosting.com/upload/fixfilename.php?msg=x%20s%20a.png

IN DATABASE = filelink "http://www.gosuhosting.com/upload/Ziph/x s a.png"

and filename "x s a.png"

 

RESPONSE:

http://www.gosuhosting.com/upload/Ziph/x s a.png = fixedlink

http://www.gosuhosting.com/upload/Ziph/x s a.png = mustfixlink

 

im pretty sure there must be something wrong with the pregreplace code but i cant find what i should use for a mysql space.

Link to comment
https://forums.phpfreaks.com/topic/124698-replacing-html-spaces/
Share on other sites

hehe im pretty sure im running php5

If I make a new php file with just

 

<?php

$str = 'foo   o';

$str = preg_replace('/\s\s+/', ' ', $str);

// This will be 'foo o' now

echo $str;

?>

 

this one works but when i use  '/\s\s+/' this code in my php script it does not =\ like it did iin this script

 

really weird.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.