PHP - Ereg() Deprecated Error
does anyone know why I am getting the error:
Deprecated: Function ereg() is deprecated on line 75 ? here is line 75 (line 3, the seond if statement): if($form_cc_type == 'visa') { if(!ereg('^4[0-9]{12}([0-9]{3})?$', $form_cc_number)) { $form_error = "Invalid number"; } } I am assuming I would get a simular error on all the ereg lines... if($form_cc_type == 'visa') { if(!ereg('^4[0-9]{12}([0-9]{3})?$', $form_cc_number)) { $form_error = "Invalid number"; } } elseif($form_cc_type == 'mastercard') { if(!ereg('^5[1-5][0-9]{14}$', $form_cc_number)) { $form_error = "Invalid number"; } } elseif($form_cc_type == 'americanexpress') { if(!ereg('^3[47][0-9]{13}$', $form_cc_number)) { $form_error = "Invalid number"; } } elseif($form_cc_type == 'diners') { if(!ereg('^3(0[0-5]|[68][0-9])[0-9]{11}$', $form_cc_number)) { $form_error = "Invalid number"; } } elseif($form_cc_type == 'discover') { if(!ereg('^6011[0-9]{12}$', $form_cc_number)) { $form_error = "Invalid number"; } } Similar TutorialsThis topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=358821.0 It seems ereg is deprecated in php 5+ so what is a good alternative? Thanks! Would anyone have the answer to solve this error message? Deprecated: Function split() is deprecated in /includes/modules/shipping/table.php on line 57 Here is the code. Line 57 is in Bold. Preg_split is suppose to work. Tried preg_explode but that didn't work. Appreciate any help! $table_cost = preg_split("/[:,]/" , MODULE_SHIPPING_TABLE_COST); $size = sizeof($table_cost); for ($i=0, $n=$size; $i<$n; $i+=2) { if ($order_total <= $table_cost[$i]) { $shipping = $table_cost[$i+1]; break; } } I have configure Xampp my site is fully functional except for the error Deprecated: Function split() is deprecated in C:\Images_Database\imagesdb\htdocs\jpserver\system\frameworks\read_site_info.php on line 15 Line 15 code shown Below $sub_folders = split("/", $_SERVER["SCRIPT_NAME"]); how to split in a proper way can any one help me God Blessings This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=359592.0 I am working on a project at the end of a text book called Beginning PHP MySQL Development which is published by Pawprints Learning Technologies. I am developing the files in NetBeans and using WAMP server. I get this error from the process_insert.php file "Deprecated: MySQL_real_escape_string():..."
I can't copy and paste so I attached my files. Can anyone help?
Attached Files
Add Product_php.htm 1.94KB
1 downloads
index.php 1.24KB
0 downloads
add_product.php 1.33KB
0 downloads
process_insert.php 1.19KB
0 downloads
db.connect.php 185bytes
0 downloads Continue from mysql_num_rows() thread which was fixed. I am having a problem with my log in script. Especially with this one below. Please help me in this one. I got this " Deprecated: Function session_register() is deprecated in... " by using this code: Quote " <?php session_start(); if(!session_is_registered($uname)) { header("location: mainpage.php"); } ?> <html> <head> </head> <body> Log in Successful </body> </html> " Any suggestions please, on how to fix it? Thanks in advance. How to solve this error out PHP Deprecated: Function ereg_replace() is deprecated in using this code Code: [Select] $shoutcast_on_off =''; $scsuccs = ''; $listenlink = ''.$scdef.''; $scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30); if(!$scfp) { $scsuccs=1; } $page = ''; if($scsuccs!=1){ fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n"); while(!feof($scfp)) { $page .= fgets($scfp, 1000); } $loop = array("STREAMSTATUS"); $y=0; while($loop[$y]!=''){ $pageed = ereg_replace(".*<$loop[$y]>", "", $page); $scphp = strtolower($loop[$y]); $$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed); $y++; } fclose($scfp); } $online1 = ''; if ($streamstatus == "1") { $online1 = '<center><img src="'.$BASEURL.'/styles/'.$theme.'/theme_images/DJ.png" border="0" height="150"></center><br> <center><a href="'.$BASEURL.':'.$scport.'/listen.pls"><img src="'.$BASEURL.'/styles/'.$theme.'/theme_images/klausom.png" width="150px" height="auto"></a></center>'; } else { $online2 = ''; $online2 = '<center><img src="'.$BASEURL.'/styles/'.$theme.'/theme_images/off.png" border="0" height="150"></center>'; } // BEGIN Plugin: shoutcast_on_off $shoutcast_on_off = $online1.$online2; // END Plugin: shoutcast_on_off eval("\$shoutcast = \"".$TSUE['TSUE_Template']->LoadTemplate('shoutcast')."\";"); return $shoutcast; Can anyone help me with this - I don't normally do coding.
I've just moved an old site onto new hosting and I'm getting this message: Deprecated: Function ereg_replace() is deprecated
The code looks like this:
if( preg_match( '/sl/i', $sOption ) )
$sContent = addslashes( $sContent );
else
$sContent = stripslashes( $sContent );
$sContent = ereg_replace( "\r", '', $sContent );
if( preg_match( '/len/i', $sOption ) )
$sContent = checkLengthOfTxt( $sContent );
I changed it to look like this:
if( preg_match( '/sl/i', $sOption ) )
$sContent = addslashes( $sContent );
else
$sContent = stripslashes( $sContent );
$sContent = preg_replace( "\r", '', $sContent );
if( preg_match( '/len/i', $sOption ) )
$sContent = checkLengthOfTxt( $sContent );
But now get this warning message:
Warning: preg_replace() [function.preg-replace]: Empty regular expression
I didn't build the site so I don't even know what the script is trying to do - forgive my ignorance!
Hi, I wonder if someone could help me, Just moved to a new server running PHP5 and getting the "Deprecated: Function sql_regcase() is deprecated" error, I don't want to disable the messages in php.ini, I would prefer to get the coding right. The error relates to the anti-injection function posted below:- Code: [Select] function anti_injection($sql) { // removes words that contain sql syntax $s = array("`","~","!","@","#","$","%","^","&","*","(",")","+","=","[","]",";","<",">","http","//","www"); $sql = str_replace($s, "", $sql); $sql = preg_replace(sql_regcase("/(from|truncate|expalin|select|insert|delete|where|update|empty|drop table|limit|show tables|#|\*|--|\\\\)/"),"",$sql); $sql = trim($sql); // strip whitespace $sql = strip_tags($sql); // strip HTML and PHP tags $sql = addslashes($sql); // quote string with slashes return $sql; } If anyone can help recode the snippet it would be greatly appreciated. Thanks Ian Hi, My host upgrade PHP yesterday and broke some code on my site. My developer is not avail... ERROR MSSG: Deprecated: Function session_is_registered() is deprecated in...followed by directory Here's the live of code that contains the error. if(!isset($_POST[$param_name]) && !isset($_GET[$param_name]) && session_is_registered($param_name)) Im assuming it has to do with "session_is_registered". Any ideas? thanks. Can anyone help me fix this problem: Deprecated: Function session_is_registered() is deprecated in/includes/functions/sessions.php on line 81 The code is: function tep_session_is_registered($variable) { return session_is_registered($variable); } function tep_session_unregister($variable) { return session_unregister($variable); } Fairly new to PHP and would greatly appreciate any help! I'm sure this issue has been addressed before, but as I can't find anything on google OR bing, I've resorted to asking it he Since, ereg and eregi are deprecated in PHP5, how do you test strings using regular expressions? Is there a new function for this? EDIT: I also looked on php.net, but all it says is its deprecated in PHP5. I didn't see any links to the new function(s) that have replaced the former. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=320413.0 Hi: Is it possible to use the ereg() function in a file upload script so that the ereg() can recognize whether or not the file type is a .jpg, .gif, .png? I already figured out how to do it without using the ereg() function - but I'm just interested to know if it is possible using ereg()..if so, could you provide me with an example? I'm also a bit confused as to how to use ereg() to recognize file types. Here;s what I've done: Code: [Select] function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } Thanks! Hi, I currently have some PHP scripts that verify form data using ereg() as follows: if (ereg(".",$var1)==0) { //do something } where instead of the argument "." I also use "\@" or "\....*", etc. to test whether certain form input is in the correct format (e.g. testing for a valid email address, etc.). However, I have understood that ereg() is being deprecated. What is the best/easiest function to replace ereg() with? Thanks! This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=347016.0 Hi All, Good day, I am looking for the replacement for session_is_registered. anyone has any idea? Code: [Select] <? session_start(); if(!session_is_registered(myusername)){ header("location:main_login.php"); } ?> <html> <body> Login Successful </body> </html> Thank you very much I am having difficulties in resolving this issue... Deprecated: mysql_db_query() [function.mysql-db-query]: This function is deprecated; use mysql_query() instead I do what it asks and then I get the following error message... ERROR: INSERT INTO customers (name, age) VALUES ('', 'Joe' '40') Added Show Records if ($_SERVER['REQUEST_METHOD'] == "POST") { // Form Values $id = ""; $name = $_POST['name']; $age = $_POST['age']; $SQL = " INSERT INTO customers "; $SQL = $SQL . " (name, age) VALUES "; $SQL = $SQL . " ('$id', '$name' '$age') "; $result = mysql_db_query($database,"$SQL"); if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } echo ("Added\n"); } Thanks for any help in advance... |