Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 19-04-08
accelerator's Avatar
Online shopping rocks!
 
Join Date: Nov 2004
Location: England
Posts: 1,177
Thanks: 3
Thanked 5 Times in 5 Posts
accelerator is an unknown quantity at this point
  How do I rewrite this as a php function?

Hi All

When I pull each value from my database into a form field, I need to prepare the data as follows:

<?=htmlspecialchars(stripslashes($row[3]), ENT_QUOTES)?>

How would I rewrite the above functionality as a function so that I can easily apply the functionality to every form field without needing to do so much typing?

Thanks all

Accelerator
__________________
WebRef.eu - Web Development Resources for the Online Entrepreneur
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 19-04-08
Registered User
 
Join Date: Jan 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
piniyini is an unknown quantity at this point
  Re: How do I rewrite this as a php function?

PHP Code:
<?php

function do($x)
{

$x htmlspecialchars($x);
$x stripslashes($xENT_QUOTES);

return 
$x;
}

?>
Then use it by
PHP Code:
<?php $value = do($row[3]); ?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 19-04-08
accelerator's Avatar
Online shopping rocks!
 
Join Date: Nov 2004
Location: England
Posts: 1,177
Thanks: 3
Thanked 5 Times in 5 Posts
accelerator is an unknown quantity at this point
  Re: How do I rewrite this as a php function?

That's great, thanks very much.
__________________
WebRef.eu - Web Development Resources for the Online Entrepreneur
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 19-04-08
tbp tbp is offline
Registered User
 
Join Date: Dec 2006
Posts: 1,905
Thanks: 0
Thanked 8 Times in 8 Posts
tbp is an unknown quantity at this point
  Re: How do I rewrite this as a php function?

PHP Code:
function clean_string($string){
  
$result htmlspecialchars(stripslashes($string), ENT_QUOTES);
  return 
$result;
}

echo 
clean_string($row[3]); 
Just wrap clean_string() round the value to be displayed
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 19-04-08
accelerator's Avatar
Online shopping rocks!
 
Join Date: Nov 2004
Location: England
Posts: 1,177
Thanks: 3
Thanked 5 Times in 5 Posts
accelerator is an unknown quantity at this point
  Re: How do I rewrite this as a php function?

Yes, cheers guys, I've got this working now
__________________
WebRef.eu - Web Development Resources for the Online Entrepreneur
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Internal PHP Processing Error (#99911) Donk Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 1 20-02-06 04:50 PM
PHP String Function Remove Last X Chr of String scifind Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 3 08-07-05 08:42 AM
PHP mail() function and spam filters giveasyouget Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 3 08-05-05 07:50 PM
Anyone anygood with xml, php, mysql and Affiliate Window AnnonnyMouse The Affiliate Marketing Lounge 1 23-09-04 11:00 AM
PHP or Browser Timeout? Barry Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 6 28-04-04 01:04 PM


Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7