Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 02-29-2012, 12:59 AM
MissTa's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 04-02-10
Location: Thailand
Posts: 171
iTrader: 0 / 0%
depreciate function, how to fix

Hi,
I have following code and day depreciated, how to replace?

Deprecated: Function session_register()
PHP Code:
function valid_email($address) {
      if (
ereg('^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$'$address)) return true;
      else return 
false;
    } 
Deprecated: Function ereg()
PHP Code:
if ($HTTP_POST_VARS) {
        while (list (
$key$val) = each ($HTTP_POST_VARS)) {
            
session_register("c$key");
            
$_SESSION["c$key"] = $val;
        }
    } 
 
Reply With Quote
  #2 (permalink)  
Old 02-29-2012, 02:01 AM
GMF's Avatar
GMF GMF is offline
Contributing Member
Latest Blog:
None

 
Join Date: 11-03-11
Location: Austria
Posts: 1,213
iTrader: 0 / 0%
Instead of ereg() use preg_match()
Code:
http://at.php.net/manual/en/function.preg-match.php
Simply don't use session_register(). It is enough to do this $_SESSION["c$key"] = $val;
Code:
http://at.php.net/session_register
 
Reply With Quote
  #3 (permalink)  
Old 02-29-2012, 02:06 AM
MissTa's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 04-02-10
Location: Thailand
Posts: 171
iTrader: 0 / 0%
thank you very much
 
Reply With Quote
  #4 (permalink)  
Old 02-29-2012, 02:10 AM
GMF's Avatar
GMF GMF is offline
Contributing Member
Latest Blog:
None

 
Join Date: 11-03-11
Location: Austria
Posts: 1,213
iTrader: 0 / 0%
No problem. If you stumble upon another deprecated function just go to

Code:
http://www.php.net/manual/en/index.php
and search for the function. You'll see if it is deprecated and an alternative.
 
Reply With Quote
  #5 (permalink)  
Old 02-29-2012, 02:28 AM
MissTa's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 04-02-10
Location: Thailand
Posts: 171
iTrader: 0 / 0%
This one still not work
PHP Code:
function valid_email($address) {
      if (
preg_match('^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$'$address)) return true;
      else return 
false;
    } 
say
Warning: preg_match() [function.preg-match]: No ending delimiter '^' f
 
Reply With Quote
  #6 (permalink)  
Old 02-29-2012, 02:49 AM
GMF's Avatar
GMF GMF is offline
Contributing Member
Latest Blog:
None

 
Join Date: 11-03-11
Location: Austria
Posts: 1,213
iTrader: 0 / 0%
God, I never really worked with regex, but I figured out whats wrong. You need to add / one at the beginning and one at the end. Like this

PHP Code:
function valid_email($address) {
      if (
preg_match('/^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/'$address)) return true;
      else return 
false;
    } 
old
'^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$'

new
'/^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/'
 
Reply With Quote
  #7 (permalink)  
Old 02-29-2012, 03:00 AM
MissTa's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 04-02-10
Location: Thailand
Posts: 171
iTrader: 0 / 0%
That worked Tanks again
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP: function from another function softgroups Coding Forum 3 12-20-2011 01:26 AM
function parameters gilbertsavier Coding Forum 1 07-15-2009 06:17 PM
js function issue ag3nt42 Coding Forum 8 05-12-2008 09:45 AM
function SymError GoldDust Coding Forum 3 02-25-2004 06:19 AM
CSS Function Reference Leader of Men Coding Forum 4 02-03-2004 12:11 PM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 02:51 PM.
Powered by vBulletin
Copyright © 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2014 Escalate Media




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.