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

Link to comment
Share on other sites

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.