ecabrera Posted March 22, 2012 Share Posted March 22, 2012 why is it that when i saved it adds a break tag i dont understhand heres the code i cant find it its only when i save or remove a video and save it it has a break <?php require "scripts/connect.php"; if($_POST['submitbtn']){ $video1 = mysql_real_escape_string(html_entity_decode($_POST['video1'])); $video2 = mysql_real_escape_string(html_entity_decode($_POST['video2'])); $video3 = mysql_real_escape_string(html_entity_decode($_POST['video3'])); $video4 = mysql_real_escape_string(html_entity_decode($_POST['video4'])); if($video1){ if($video2){ if($video3){ if($video4){ $query = mysql_query("UPDATE videos SET video1='$video1',video2='$video2',video3='$video3',video4='$video4'"); header("location: http://www.mywebsite.com/admin/editvideos"); }else $msg = "PLEASE FILL IN"; }else $msg = "PLEASE FILL IN"; }else $msg = "PLEASE FILL IN"; }else $msg = "PLEASE FILL IN"; } mysql_close(); ?> <?php include "header.php";?> <?php if($email){?> <?php include "inc/nav.php"; ?> <div id="righthomecontent"> <?php require "scripts/connect.php"; $query = mysql_query("SELECT * FROM videos"); $rows = mysql_fetch_assoc($query); $video1 = stripslashes($rows['video1']); $video2 = stripslashes($rows['video2']); $video3 = stripslashes($rows['video3']); $video4 = stripslashes($rows['video4']); mysql_close(); ?> <center>MUST USE THIS IN VIDEOS ?wmode=opaque"</center><br> <center>All videos are Width='220' and Height='240'</center><br> <form class="editvideoform" action="editvideos" method="post"> <table> <tr> <td></td> <td><?php echo $msg;?></td> </tr> <tr> <td>VIDEO 1</td> <td><textarea cols=25 rows=10 name="video1"><?php echo $video1;?></textarea></td> </tr> <tr> <td>VIDEO 2</td> <td><textarea cols=25 rows=10 name="video2"><?php echo $video2;?></textarea></td> </tr> <tr> <td>VIDEO 3</td> <td><textarea cols=25 rows=10 name="video3"><?php echo $video3;?></textarea></td> </tr> <tr> <td>VIDEO 4</td> <td><textarea cols=25 rows=10 name="video4"><?php echo $video4;?></textarea></td> </tr> <tr> <td></td> <td><input type="submit" name="submitbtn" value="SUBMIT" /></td> </tr> </table> </form> </div> <?php } else { echo "<center><h1>PLEASE LOGIN</h1></center>"; } ?> <?php include "footer.php";?> Quote Link to comment https://forums.phpfreaks.com/topic/259522-break-gone-wild/ Share on other sites More sharing options...
ecabrera Posted March 23, 2012 Author Share Posted March 23, 2012 any ideas why this is happening Quote Link to comment https://forums.phpfreaks.com/topic/259522-break-gone-wild/#findComment-1330378 Share on other sites More sharing options...
PFMaBiSmAd Posted March 23, 2012 Share Posted March 23, 2012 Without an example showing what you are inputting as data and what you are getting as output (shows where and what the problem is), there's not much help anyone can give. Quote Link to comment https://forums.phpfreaks.com/topic/259522-break-gone-wild/#findComment-1330494 Share on other sites More sharing options...
onlyican Posted March 23, 2012 Share Posted March 23, 2012 I could only assume that the textarea field has a blank line in it. And html_entity_decode() is converting that to a br tag Quote Link to comment https://forums.phpfreaks.com/topic/259522-break-gone-wild/#findComment-1330495 Share on other sites More sharing options...
ecabrera Posted March 23, 2012 Author Share Posted March 23, 2012 ok so if i dont have anything thing to add in the video1 and leave it blank and submited in phpmyadmin i get a <br> Quote Link to comment https://forums.phpfreaks.com/topic/259522-break-gone-wild/#findComment-1330597 Share on other sites More sharing options...
darkfreaks Posted March 24, 2012 Share Posted March 24, 2012 your carriage returns aren't being escaped try something like this $string = str_replace("chr(13)", "" , $string); Quote Link to comment https://forums.phpfreaks.com/topic/259522-break-gone-wild/#findComment-1330640 Share on other sites More sharing options...
PFMaBiSmAd Posted March 25, 2012 Share Posted March 25, 2012 Since the code you posted won't execute the UPDATE query when you leave any of the textarea's empty, either the <br> in the database table is there from your original INSERT query or you have some code you haven't posted, such as a WYSIWYG javascript editor on the page. Quote Link to comment https://forums.phpfreaks.com/topic/259522-break-gone-wild/#findComment-1330860 Share on other sites More sharing options...
ecabrera Posted March 26, 2012 Author Share Posted March 26, 2012 well i use nicedit if that helps but it has dont that before but know it does add a break each time i add a new video Quote Link to comment https://forums.phpfreaks.com/topic/259522-break-gone-wild/#findComment-1331140 Share on other sites More sharing options...
PFMaBiSmAd Posted March 26, 2012 Share Posted March 26, 2012 That editor, probably as a workaround instead of fixing a problem, inserts a <br /> in each empty textarea, that posts as a <br> (I'm not sure where/how the space and / are removed.) If you don't enter anything in a textarea, a <br> is posted. If you do enter something, there is a <br> on the end of it. You would need to check if the posted data from each field is just a <br> and remove it. If you don't want a <br> on the end of each actual value you do enter, you would need to strip that off as well. Didn't it occur to you to mention or show up front that you had some code like a WYSIWYG (and which one) involved? You could have gotten an answer almost 4 days ago. Quote Link to comment https://forums.phpfreaks.com/topic/259522-break-gone-wild/#findComment-1331196 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.