PHP - Strip_tags Issue When Stripping <span Style> Tag
Hi All, Hope you can help, I'm having problems with the strip_tags code, I'm having problems getting it to work with certain tags, the code below shows my issue: $print_description = <span style="color: #ff99cc; font-size: large">4 x BLUE handmade clay feet</span> $print_description = strip_tags($print_description); //remove html because of danger of broken tags I've cut down the code to show the problem. So I want to strip the Span tags; the problem I am having is as soon as you have a style attribute with more than one attribute and you use a ; symbol strip_tag will strip the entire content of the <span>AND ALL THE TEXT IN THE MIDDLE</span>. I want to just be left with '4 x BLUE handmade clay feet' If I take the ; out and just have one style it works fine. I am using tiny_MCE so don't have the option not to use what it makes me use. I've searched the net and have tried a few things to make it work but now I'm at a loss. Any help would be gratefully received. Similar TutorialsI have a small script that prints the contents of a log on my server but it's removing tags from the output. An example would be: <username> data here is being printed as: data here removing: <username> I do not want it to strip these out of the output. How do I avoid this? Code: [Select] <? $cmd = "tail -5 /opt/mserver/server.log"; exec("$cmd 2>&1", $output); foreach($output as $outputline) { print ("$outputline\n"); } ?> So I am doing a script to read some emails coming into an address that I have piped to it. Done this before and had success. Problem now is strip_tags. Trying to remove some spurious html codes in the email the easy way or so I thought. What's happening is this
A line that contains an email address such as this:
From: <user@domain.com>
is being stripped out to this:
From: <user@domain.com>
I thought that strip_tags would just strip out the < and > chars but it is not. Any ideas?
Hi, i use strip_tags() function, but it removes string like <3, what can i use to allow this, but to disable real html tags ? Hi all, I just managed to make a little mod_rewrite rule which manages to interpret url's without the extension and calls the right file with the extension (ie. /articles calls articles.php) . But now i am left with another question which i am almost certain has nothing to do with mod_rewrite, but rather with a php trick. In case someone enters on my site www.mydomain.com/laalalalala.php How do i get rid of that last part(the extension for example)? Do i maybe have to get the GET['var'] and run it through a regex and reload the page with the stripped version? That was all i could think off but it sound so complicated. if anyone has an idea i would love to hear it cheers! P.s.s if anyone want's that rewrite rule, let me know. I saw quite some people on the internet looking for it Ok, I'm stumped on this one. I'm looking to strip html code from the following output: Code: [Select] <?php echo substr($f7,0,60); ?> How do I insert the strip_tags into that statement? It seems like there should be a dedicated php function to strip a SPECIFIC tag, rather than the functionality of strip_tags. I'm using this: Quote function stripSingleTags($tags, $string) { foreach( $tags as $tag ) { $string = preg_replace('#</?'.$tag.'[^>]*>#is', '', $string); } return $string; } But this will not help me if for example I want to trip out scripts <script> ... </script>. Is there a better way? Heya I have a problem with stripping HTML from some text with strip_tags. I am in the unfortunate situation to be working on a system where the previous developer loved to throw HTML, CSS and JavaScript straight into the database and not filter it when extracting it. Therefore, I need to filter some of the crap he threw in. Here is some code: $details = Person::getPersonDetails($id); // Returns MySQL object data set (I know!) from mysql_fetch_object echo strip_tags($details->description); // I want to remove HTML from the description property, but the HTML is still displayed after using strip_tags Any ideas? Thanks! Hey guys! I tried to use strip_tags() on this string, but the function will return a null-string for some reason? Any idea why, and any suggestion how to solve this? $string = '<Word.Bookmark.Start" w:name="a"/><w:p><w:pPr><w:jc w:val="center"/><w:rPr><w:sz w:val="16"/><w:sz-cs w:val="16"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:b/><w:highlight w:val="light-gray"/></w:rPr><w:t>Engagerad</w:t></w:r><aml:annotation aml:id="0" w:type="Word.Bookmark.End>'; echo strip_tags($string); // returns nothing, nada... thank you Hi, this is probably really simple for the majority here, but it's catching me out. I want to know what I need to add to the code below to strip <> HTML tags from the field post_title. Hope somebody can help. Thanks in advance. Code: [Select] <?php mysql_connect("********", "********", "********") or die(mysql_error()); mysql_select_db("website_news") or die(mysql_error()); $data = mysql_query("SELECT * FROM news_posts ORDER BY post_date DESC LIMIT 0, 5") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { Print "<font color='black' face='arial'><li><a href='/website/news/?p=".$info['ID'] . "'>"; if ( strlen($info['post_title']) > 60) { $PostTitle = substr($info['post_title'], 0, 60); print $PostTitle. "..."; } else { print $info['post_title']; } Print "</a> <font color=#666666><i> - posted on "; $date = date('j M \'y', strtotime($info['post_date'])); Print $date; Print "</i>"; } ?> Hi, I'm having problems with a PHP mail handler and everything seems to be working fine except I get slashes in the message body from the form. If my input is "Please don't delete this" I get "Please don/'t delete this" in the message body, however it is striping the other tags. I'm not sure what is wrong and was hoping for a bit of help to figure this out. Here is the code: Code: [Select] <?php $owner_email = $_POST["owner_email"]; $headers = 'From:' . $_POST["email"]; $subject = 'Website contact inquiry from ' . $_POST["name"]; $messageBody = ""; $messageBody .= '<p>------------------ Contact Details ------------------' . '</p>' . "\n"; $messageBody .= '<p>Name: ' . $_POST["name"] . '</p>' . "\n"; $messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n"; $messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n"; $messageBody .= '<p>----------------------------------------------------------' . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; $messageBody .= '<p>' . $_POST['message'] . '</p>' . "\n"; if($_POST["stripHTML"] == 'true'){ $messageBody = strip_tags($messageBody); } try{ if(!mail($owner_email, $subject, $messageBody, $headers)){ throw new Exception('mail failed'); }else{ echo 'mail sent'; } }catch(Exception $e){ echo $e->getMessage() ."\n"; } ?> Hi all, Thanks for reading. I have this code: Code: [Select] $message = strip_tags($_POST['message'], '<p><strong><em>'); My question is however, is there a way that I could disable the onmouseover features in those tags? Thank you. i'm having problems with apostrophes causing an error on my contact form. I've tried stripslash and also str_replace but i can't get it to work. what am i doing wrong? thanks Code: [Select] <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "test@test.com"; $email_subject = "test"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['contact_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } foreach($_POST['check'] as $value) { $check_msg .= "Checked: $value\n"; } $contact_name = str_replace("'", "&#039;", $contact_name); $contact_name = $_POST['contact_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$contact_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Contact Name: ".clean_string($contact_name)."\n"; $email_message .= "Agency/Company Name: ".clean_string($last_name)."\n"; $email_message .= "Email Address: ".clean_string($email_from)."\n"; $email_message .= "Dates Required: ".clean_string($telephone)."\n"; $email_message .= "Type Required: ".clean_string($check_msg)."\n"; $email_message .= "Any other info: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> thanks <?php } ?> In querying my database, I'm Selecting nameFirst and nameLast, and it produces a name like Joe Smith. I'm trying to match a photo with the name. Right now I'm uploading photos into a folder naming the file (e.g. SmithJoe.jpg). For reasons that involve writers being able to upload and access photos, I'm trying to use an image plugin. When uploading photos, it strips capital letters, so SmithJoe,jpg goes in as smithjoe.jpg, and it's not matching my database query. Here is the code I'm working with that works quite well with this one exception: $query = 'SELECT * FROM wp_playerRank'; $results = mysql_query($query); while($line = mysql_fetch_assoc($results)) { if ($line['wpID'] == $wp_tagID) { echo '<div class="player">'; // Here is the code that produces the image. I need to get rid of capital letters for ease of use echo '<div><img src="/wp-content/uploads/' . $line['nameLast'] . $line['nameFirst'] . '.jpg"></div>'; echo '<div class="playerData">' . $line['height'] . ' '; if ($line['position'] == 'PG') {echo 'Point Guard';} elseif ($line['position'] == 'SG') {echo 'Shooting Guard';} elseif ($line['position'] == 'SF') {echo 'Small Forward';} elseif ($line['position'] == 'PF') {echo 'Power Forward';} elseif ($line['position'] == 'C') {echo 'Center';} echo '</div>'; echo '<div class="playerData">' . $line['hschool'] . '</div>'; echo '<div class="playerData">' . $line['summer'] . '</div>'; echo '<div class="playerData">Class of ' .$line['year'] . '</div>'; if ($line['committed'] == 'y') { echo '<div> <br>Committed to <strong>'. $line['college'] . '</strong></div> ';} } } This is what I have $eeee = $_POST['forum_reply']; $eeee = strip_tags($eeee, '<p>'); echo $eeee; this is what prints out Quote Untitled document testinggg this is a print_r of $_Post Quote Array ( [forum_reply] => testinggg [form_reply_submit] => Reply ) Please someone tell me what in binary's name is going on! Hey guys i got an invoice form that has the totals in a span id
SUB ::<span id="small_total"></span><br /> TPS :: <span id="tps"></span><br /> TVQ :: <span id="tvq"></span><br /> GRAND TOTAL :: <span id="grand_total"></span><br />so its part of a form,when i submit to add to databse i can't seem to figure out how to get the values of the id? i have tried a few things with no success.. exp in the add.php page(form submit action) $GT = "<script language='javascript'>document.getElementById(grand_total);</script>"; Is it possible to have an effect on a span? I have a peice of javascript that changes the contents of a span and want a css effect to take place when it has changed: .spanname{ -webkit-transition: all 300ms ease-in-out; -moz-transition: all 300ms ease-in-out; -ms-transition: all 300ms ease-in-out; -o-transition: all 300ms ease-in-out; transition: all 300ms ease-in-out; }Thanks hey guys i have like 4 spans which show at the bottom right hand side of my page which are currently overlapping...i've tried to display as block but no success. any help would be greatful...thank you
live demo: http://jsfiddle.net/sr5fta4m/
here is my code:
.notification { padding: 15px; margin-bottom: 20px; border: 1px solid #eed3d7; border-radius: 4px; position: absolute; bottom: 0px; right: 21px; float: right; clear: right; diplay: block; } #alert-notification { color: white; background-color: #DA4453; } #success-notification { color: white; background-color: #37BC9B; } #information-notification { color: white; background-color: #4A89DC; } #error-notification { color: white; background-color: #DA4453; } <span class="notification" id="success-notification">Registration complete. Please check your mail.</span> <span class="notification" id="alert-notification">Account already activated.</span> <span class="notification" id="information-notification">Please check you email.</span> <span class="notification" id="error-notification">Wrong login detials.</span> Edited by Destramic, 17 December 2014 - 08:33 PM. onkeydown="this.style.fontStyle='normal';"How can I add color: #000; to this? Thanks, |