PHP - Needing Help With Updating Deprecated Php Commands
Hi. I have our company website running on an older Joomla and so running PHP v5.6. We were encountering some issues so I have been rebuilding on latest Joomla version and will run the latest PHP now but I have encountered an issue (and I'm no php expert). We have a brochure page on the site where a user can select one or more brochures from a list, and then have to complete their details in a form and an email is sent to them with the brochures as a pdf attachment. We also receive an email notification with the user details and what brochure was selected so we can follow up on the lead. So I have the html coding for the web page, which links back to a php file with the brochures listed in an array and using phpmailer to send. Would someone be able to assist me by looking at the current files I have and showing me how to update the deprecated php commands - and also to ensure that the fields info is being properly verified etc. Thank you! Similar TutorialsWould 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=358821.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=359592.0 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. 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; 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. 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! 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 All, Hi, I am trying to create a PHP script ("repair-correct.php") in order to run some CLI commands without using PuTTy - The CLI commands are needed to repair/correct the execution of a web application named Mautic. Shared web host account with PHP 7.0 URL: https://www.myserver.com Mautic directory: https://www.myserver.com/mautic
What I want to do is:
Step1: Change ownership of files and folders To find out which user Apache is running as, I want to execute the following command and take note of the first entry in the line which is returned: ps aux | grep apache2 I want to use this information to find the groups with the following command groups apache_user (where apache_user is the user I identified from the first step above) To reset the ownership of files and folders, I want to use the following command (ensuring that I replace apache_user and apache_group with the values identified in the steps above): sudo chown -R apache_user:apache_group With this command I want to change ownership, using the -R flag which means recursively - including all files/folders within that location.
Step 2: Reset the file and folder permissions
find . -type f -not -perm 644 -exec chmod 644 {} +
Thanks so much for your help in solving this problem!
Best, Tony
This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=306588.0 How can i switch between the 2 lines below in my function. At the moment the bottom line is ignored: /* Determine if user is logged in */ $this->logged_in = $this->checkLogin(); /* Determine if client is logged in */ $this->logged_in_Client = $this->checkLoginClient(); Code: [Select] function startSession(){ global $database; //The database connection session_start(); //Tell PHP to start the session /* Determine if user is logged in */ $this->logged_in = $this->checkLogin(); /* Determine if client is logged in */ $this->logged_in_Client = $this->checkLoginClient(); if($this->logged_in){ $database->addActiveUser($this->username, $this->time); } if($this->logged_in_Client){ $database->addActiveClient($this->clientname, $this->time); } /* Set referrer page */ if(isset($_SESSION['url'])){ $this->referrer = $_SESSION['url']; }else{ $this->referrer = "/"; } /* Set current url */ $this->url = $_SESSION['url'] = $_SERVER['REQUEST_URI']; } Im having trouble with this wondering if someone could help me out please if (isset($_POST['escape'])) { || if (isset($_POST['suicide'])) { its giving me a error on the || im writing it so that one or the other has to happend. is this the correct way to use this? When i get onto a new server, i put a php file on it and see what versions of php sqlite and mysql there are. For some reason, when i put it on this server, it does not show anything ... 2 of the lines: Code: [Select] echo sqlite_libversion(); echo phpversion(); Other php commands work and i am able to call simple methods and what not. But for some reason those commands and a sqlite query is not working . Any ideas? So ive created a script sometime back for entering movies into my database, i simply fill in the movie title, URL for it and then from a drop down menu i select what category from the catagories table that it fits in. eventually after time some of the movies need to be placed in a different category. currently the only way to do this is actually go into myphpadmin and edit within the tables. obviously way too time consuming. so im seeking to create a script that would allow me to select any given movie from my movies table (via dropdown maybe) and then change what category its assigned too, maybe also in a dropdown. heres the table structure. Movies Table ID - Title - Category - URL ---------------------------------------------------- 1 - Movie 1 - 18 www..com Categories Table ID - Category Name -------------------------------- 18 - Category 1 Note that the FK in movies table is Category. in my previous script from entering the movies i have it made so that when selecting the category it shows the category name instead of the ID. i hope that the same could be possible for this new script. If its not too much trouble i hope that someone could help me out on this. im totally clueless where too start. thanks! Someone wrote this script for me ages ago - works fine on php4, but having some issues with php5 and the installation & reflect changes files... In a nutshell it takes a file called state.txt (all 50 states one per line) and creates a directory for each. There is then a text file for each state, for instance Alabama.txt, which has all the cities of that state. You end up with a directory for each state with directories of each city within them. Header and footer files as well as an index.php are used for each level. Trying to use this it creates the directores for each state, but does so in the root folder rather than the actual location of the file on the particular site. I realize $_SERVER['PATH_TRANSLATED'] has been removed, but replacing this with $_SERVER['SCRIPT_FILENAME'] doesn't seem to correct the issue. install.php Code: [Select] <?php set_time_limit(0) ; $arr = explode("/",$_SERVER['PATH_TRANSLATED']); $ct = count($arr); unset($arr[$ct-1]); $path=implode("/",$arr); $path=$path."/"; if(is_file($path."state.txt")) { $lines = file($path."state.txt"); if($lines) { foreach($lines as $line) { if($line) { $state = trim($line); if(!is_dir($state)) { @mkdir($state,0777); if(is_file($path."copieble/state/index.php")) { $from = $path."copieble/state/index.php"; $to = $path.$state."/index.php"; @copy($from,$to); } } } } } } @chdir($path); $handle=opendir('.'); while (($file = readdir($handle))!==false) { @chdir($path); if (($file != ".") && ($file != "..")) { if(is_dir($file) && $file != "copieble" && $file !="_vti_cnf") { if(is_file($path.$file.".txt")) { $lines = file($path.$file.".txt"); if($lines) { foreach($lines as $line) { if($line) { $city = trim($line); @chdir($path.$file); if(!is_dir($city)) { @mkdir($city,0777); if(is_file($path."copieble/city/index.php")) { $from = $path."copieble/city/index.php"; $to = $path.$file."/".$city."/index.php"; @copy($from,$to); } } } } } } } } } closedir($handle); include("reflect_changes.php"); ?> reflect_changes.php Code: [Select] <?php $arr = explode("/",$_SERVER['PATH_TRANSLATED']); $ct = count($arr); unset($arr[$ct-1]); $path=implode("/",$arr); $filepath=$path."/copieble/state/index.php"; //print_r($_SERVER); // Copy here the index file for all the states folder if(is_file($filepath)) { chdir($path); //echo "<br>".$path."/state"; $handle=opendir('.'); while (($file = readdir($handle))!==false) { if (($file != ".") && ($file != "..")) { if (is_dir($file) && $file !="copieble" && $file !="_vti_cnf") { $dst = $path."/".$file."/index.php"; @copy($filepath,$dst); } } } closedir($handle); } // Copy here the index file for all the cities in each states $filepath = $path."/copieble/city/index.php"; if(is_file($filepath)) { if(is_dir($path)) { chdir($path); //echo "<br>".$path."/state"; $handle=opendir('.'); while (($file = readdir($handle))!==false) { if (($file != ".") && ($file != "..")) { if (is_dir($file) && $file != "copieble" && $file !="_vti_cnf") { chdir($path."/".$file); $handle1=opendir('.'); while (($file1 = readdir($handle1))!==false) { if (($file1 != ".") && ($file1 != "..")) { if (is_dir($file1)) { $dst = $path."/".$file."/".$file1."/index.php"; @copy($filepath,$dst); } } } closedir($handle1); } chdir($path); } } closedir($handle); } } ?> 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... here my code <html> <head><title>TESTING</title></head> <body> <form method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>"/> email: <input type=text name=email value="" /><br/> feedback: <input type=text name=ex value=""/><br/> <input type="submit" value="submit" /><br/> </body> </html> <?php $email = $_GET['email']; $ex = $_GET['ex']; if(!eregi('^[a-zA-Z0-9\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z]+$',$email)){ echo 'invalid email address<br/>'; } else { echo 'good to go<br/>'; } if(eregi('money|brooklyn|new york' ,$ex)){ echo '1'; } else { echo '0'; } ?> The code works fine but when i put on my error reporting i get that eregi is deprecated, now if eregi is depreciated which function should i use ? or should i just suppress the error ? |