I am having something strange happen.
My script is for editing information.
When I send the $_POST from my textarea to my php page. It sanitizes and inserts correctly, but I also want to re-output the data if called upon again. So i am basically using jquery $post to send and retrieve the information.
It all works great, except when I call the info back with the edit button and function "onmousedown" it is not giving me the correct format for my parameters.
If I only write on one line it comes out perfect, but if I use multiple lines it won't retain the line breaks and it chops off the closing " ' " so the function cannot be reset. Any ideas? Here is my callback echo. Thanks in advance...
The problem is in the "$againList" parameter...
$againList = $_POST['updated_songList']; // I am sending back the exact same data that was given without filter...
echo '<span><h4 style="margin-bottom:0px; font-size:14px;">'.$full_birthday.'
<a href="#" onclick="deleteSongList('.$songid.');" style="color:gray; float:right; font-weight:100; font-size:12px;">delete</a>
<a href="#" onclick="return false" onmousedown="editSongList(\''.$songid.'\', \''.$againList.'\');" style="margin-right:5px; color:gray; float:right; font-weight:100; font-size:12px;">edit</a></h4>'.$song_list.'<br /></span>';
If you need anything else let me know. Thanks!
Hmm, php has a nl2br() function that converts new line to breaks but I'm not sure that's what you are after. Does the linebreaks dissapear before or after they come to the php script?
Here is how to use nl2br();
$var = nl2br($_POST['myValue']);
Okay, so I figured it out and got it running. Thanks for all the help everyone!
Try this :
$againList = nl2br($_POST['updated_songList']);
Basically, all textarea newlines are "\n" which HTML doesn't show. nl2br() just converts them into
<br/> while displaying them. The newlines remain intact.
For the script that removes the "'" from the end, unless you show that script, you can't be helped.