Jump to content

Recommended Posts

Hello! Im working on a project and in this particular event im having a problem...

 

Lets say i have a text (stored as mediumtext) successfully saved on mysql:

 

Hello
How are you?
Im fine

 

Ok...

Now im retreveing that text with php and its being displayed like this:

 

Hello

How are you?

Im fine

 

Why is it creating enter spaces?

What am i doing wrong? or what should i change?

 

Thanx in advance!

Cheers,

PHP

//retrieve the lyrics from the selected song
if ($action == "loadLyrics")
{
$title=$_POST['txtTitle'];

        $result = mysql_query("SELECT title, link, lyrics FROM videla_songs WHERE title = '$title'"); 
        $cant = 0; 
        while($row=mysql_fetch_array($result)){ 
            echo "title$cant=$row[title]&link$cant=$row[link]&lyrics$cant=$row[lyrics]&"; 
            $cant++; 
        } 
        echo "cant=$cant"; 
}

 

RELEVANT FLASH CODE:

txtSongLyrics.text = content_lv.lyrics0;

Try this, your code looks weird (and you don't need that extra ampersand at the end).

 

echo "title" . $cant . "=" . $row['title'] . "&link" . $cant . "=" . $row['link'] . "&lyrics" . " . $cant . "=" . $row['lyrics'] . "&";

Thanx for your reply!

Correct code:

echo "title" . $cant . "=" . $row['title'] . "&link" . $cant . "=" . $row['link'] . "&lyrics" . $cant . "=" . $row['lyrics'] . "&";

 

Is doing the same...the enter spaces are still being performed...

 

Any other ideas, anyone?

 

Thanx for the help!

Cheers,

If the spaces are at the beginning or end of the deal you can use trim on each variable to trim them out.

 

If they are mixed in and I take "enter spaces" as a new line you can try using str_replace

 

<?php
$test = "This is a test\n of the emergency\r\n brodcast system";
$replace = array("\n", "\r\n");
$test = str_replace($replace, "", $test);
?>

 

Either way that should help you out a bit.

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.