Deprecated: Function … is deprecated in PHP

Symptom:

Shows errors like below on your Joomla, Drupal or in any other php coded webpage.

  • Deprecated: Function ereg() is deprecated in …
  • Deprecated: Function split() is deprecated in …
  • Deprecated: Function set_magic_quotes_runtime() in …
  • …will add more…Please let me know if you find more.

Reason:

Those functions got replaced with alternate ones. (Sorry that I don’t know the reason behind that. May be the new ones might have some new features). Also I experienced this problem after upgrading PHP engine on my server.

Fix:

ereg() fix:

FTP the web server and open the file showing error, search for “ereg” and replace ereg(…) with mb_ereg(…). The syntax is same for both. (Try this and keep it if it works. It will work 90% sure.)

split() fix:

FTP the web server and open the file showing error, search for “split” and replace split(…) with explode(…). (Same as above.)

set_magic_quotes_runtime() fix:

Replace the below line showing error

set_magic_quotes_runtime(0);

with below code

// Check if magic_quotes_runtime is active
if(get_magic_quotes_runtime())
{
// Deactivate
set_magic_quotes_runtime(false);
}

Note: More findings will be added to this post as and when I experience them. Please comment below if you had experienced and fixed any other deprecations.

Tip: Display unicode data from mySQL DB on a website in PHP.

Before we start we need to make mySQL database capable of supporting unicode characters. For that we need to change the database collation or the table collation to utf8_unicode_ci. This can be done with phpmyadmin portal.

  1. Click the table you need to change.
  2. select Structure tab.
  3. Check the required column and click change or edit.
  4. From the collation drop down select utf8_unicode_ci.
  5. Press Go.

Click here to read more

Error: Could not find any IP address that this SQL Server instance depends upon.

Problem:

We had a requirement to change the SQL Server Fail over cluster group Virtual server name. We did that change through the cluster administrator. That SQL Server was 2008 Enterprise running on  Windows 2008 Enterprise cluster. The change was successfully made from one node and the SQL server came online after that. But when we did fail over testing, we noticed that the SQL Server service is not coming online on the other node. The SQL Server error-log gave below errors while trying to start-up.

  • Could not find any IP address that this SQL Server instance depends upon. Make sure that the cluster service is running, that the dependency relationship between SQL Server and Network Name resources is correct, and that the IP addresses on which this SQL Server instance depends are available. Error code: 0x103.
  • Error: 17182, Severity: 16, State: 1.
  • TDSSNIClient initialization failed with error 0x103, status code 0xa. Reason: Unable to initialize the TCP/IP listener. No more data is available.
  • Error: 17182, Severity: 16, State: 1.
  • TDSSNIClient initialization failed with error 0x103, status code 0x1. Reason: Initialization failed with an infrastructure error. Check for previous errors. No more data is available.
  • Error: 17826, Severity: 18, State: 3.
  • Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.
  • Error: 17120, Severity: 16, State: 1.
  • SQL Server could not spawn FRunCM thread. Check the SQL Server error log and the Windows event logs for information about possible related problems.

Click here to continue reading this post and resolution

Changing SQL Server Collation on a SQL Server 2008 Failover Cluster

  1. Log-in to the active node.
  2. Trigger a full backup for all System and User Databases.
  3. Script out all log-ins.
  4. If there are any user databases, you will have to export the tables using BCP utility.
  5. Copy SQL Server 2008 install media folder to some local directory. For Eg: D:\SQL2008SP2
  6. Open command prompt and execute below command. Caution: This step will replace your current system databases with new ones with required collation. So please make sure you will be able to restore all logins and the user databases back after this activity.
    D:\SQL2008SP2\Setup.exe /QUIET /ACTION=REBUILDDATABASE
    /INSTANCENAME=MSSQLSERVER
    /SQLSYSADMINACCOUNTS=”DOMAIN\ntid” /SAPWD=strongpassword
    /SQLCOLLATION=New_Collation_Name

    Note: Please replace the values for /INSTANCENAME, /SQLSYSADMINACCOUNTS, /SAPWD and /SQLCOLLATION

    Here you go !. Your SQL server has got new collation settings now. Please let me know if incase you experienced any issues.

  7. Now restore all logins and userdatabases using the scripts generated in step 3 and the tables exported in Step 4.

Reference: http://msdn.microsoft.com/en-us/library/ms179254.aspx


Installing SQL Server 2008 failover cluster in Windows 2008 R2 cluster

Prerequisites

  1. SQL Server 2008 Standard/Enterprise/Developer edition install Media with Service pack 2.
  2. One IP address as SQL Cluster virtual IP and host-name as SQL Cluster virtual host-name. Our clients will have to use this host-name or IP to connect with this fail-over instance.
  3. One shared disk to place all our System DB files + error-logs etc
  4. Minimum two identical clustered Windows 2008 Servers.
  5. … Will be adding more. Couldn’t remember all of them at one shot. Please add any missed out points below as comments. Thanks in advance.

Method

  1. Log-in to any one node and move all the cluster resources to that node.
  2. Navigate to the media directory and execute the below command. This is to make sure we don’t move all the SQL server binary files into C drive.
    setup.exe /ACTION=INSTALLFAILOVERCLUSTER /INSTALLSHAREDDIR=”J:\Program Files\Microsoft SQL Server” /INSTALLSHAREDWOWDIR=”J:\Program Files (x86)\Microsoft SQL Server”.
  3. Follow the instructions on the setup wizard.

To be continue…

SQL Configuration Change Alerting

The below script helps in detecting, recording and alerting when ever a change is made to sp_config or SQL server configuration settings. This will help in pin-pointing any unnecessary changes happening to Our Beloved SQL Server…

create database HCLDBA go ALTER DATABASE [HCLDBA] SET RECOVERY SIMPLE WITH NO_WAIT

GO

use HCLDBA goSET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO SET ANSI_PADDING ON

GO

CREATE TABLE [dbo].[SQLConfig_Changes]( [TextData] [varchar](500) NULL, [HostName] [varchar](155) NULL, [ApplicationName] [varchar](255) NULL, [DatabaseName] [varchar](155) NULL, [LoginName] [varchar](155) NULL, [SPID] [int] NULL, [StartTime] [datetime] NULL, [EventSequence] [int] NULL ) ON [PRIMARY]

GO

SET ANSI_PADDING OFF

GO

SET NOCOUNT ON

GO

CREATE PROCEDURE dbo.usp_Capture_SQL_Config_Changes @SendEmailTo VARCHAR(255) AS CREATE TABLE #temp_cfg ( TEXTData VARCHAR(500), HostName VARCHAR(155), ApplicationName VARCHAR(255), DatabaseName VARCHAR(155), LoginName VARCHAR(155), SPID INT, StartTime DATETIME, EventSequence INT )

DECLARE @trc_path VARCHAR(500), @message VARCHAR(MAX), @message1 VARCHAR(MAX), @textdata VARCHAR(1000)

SELECT @trc_path=CONVERT(VARCHAR(500),value) FROM fn_trace_getinfo(DEFAULT) WHERE property=2

INSERT INTO #temp_cfg SELECT TEXTData,HostName,ApplicationName,DatabaseName,LoginName,SPID,StartTime,EventSequence FROM fn_trace_gettable(@trc_path,1) fn WHERE TEXTData LIKE ‘%Configur%’ AND SPID<>@@spid AND fn.EventSequence NOT IN (SELECT EventSequence FROM SQLConfig_Changes) AND TEXTData NOT LIKE ‘%Insert into #temp_cfg%’ ORDER BY StartTime DESC

INSERT INTO dbo.SQLConfig_Changes SELECT * FROM #temp_cfg

/*select TextData,HostName,ApplicationName,DatabaseName,LoginName,SPID,StartTime,EventSequence from fn_trace_gettable(@trc_path,1) fn where TextData like ‘%Configur%’ and SPID<>@@spid and fn.EventSequence not in (select EventSequence from SQLConfig_Changes) order by StartTime desc*/

–select * from SQLConfig_Changes

IF @@ROWCOUNT > 0 –select @@ROWCOUNT

BEGIN DECLARE c CURSOR FOR

SELECT LTRIM(REPLACE(SUBSTRING(TEXTData,31,250), ‘. Run the RECONFIGURE statement to install.’, ”)) FROM #temp_cfg

OPEN c

FETCH NEXT FROM c INTO @textdata

WHILE (@@FETCH_STATUS <> -1) BEGIN –FETCH c INTO @textdata

SELECT @message = @textdata + ‘on server ‘ + @@servername + CHAR(13)

EXEC msdb.dbo.sp_send_dbmail –@profile_name=’ProfileName – otherwise will use default profile’, @profile_name=’DBA’, @recipients=@SendEmailTo, @subject=’SQL Server Configuration Change Alert’, @body=@message

FETCH NEXT FROM c INTO @textdata

END CLOSE c DEALLOCATE c

END

DROP TABLE #temp_cfg

go

USE [msdb]

GO

/****** Object: Job [Detect Config Change] Script Date: 08/17/2011 12:22:12 ******/ BEGIN TRANSACTION DECLARE @ReturnCode INT SELECT @ReturnCode = 0 /****** Object: JobCategory [Data Collector] Script Date: 08/17/2011 12:22:12 ******/ IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N’Data Collector’ AND category_class=1) BEGIN EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N’JOB’, @type=N’LOCAL’, @name=N’Data Collector’ IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback

END

DECLARE @jobId BINARY(16) EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N’Detect Config Change’, @enabled=1, @notify_level_eventlog=0, @notify_level_email=0, @notify_level_netsend=0, @notify_level_page=0, @delete_level=0, @description=N’No description available.’, @category_name=N’Data Collector’, @owner_login_name=N’DOMAIN\USER’, @job_id = @jobId OUTPUT IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback /****** Object: Step [Run the Stored Proc] Script Date: 08/17/2011 12:22:13 ******/ EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N’Run the Stored Proc’, @step_id=1, @cmdexec_success_code=0, @on_success_action=1, @on_success_step_id=0, @on_fail_action=2, @on_fail_step_id=0, @retry_attempts=0, @retry_interval=0, @os_run_priority=0, @subsystem=N’TSQL’, @command=N’USE [HCLDBA] GO

DECLARE @return_value int

EXEC @return_value = [dbo].[usp_Capture_SQL_Config_Changes] @SendEmailTo = N”emailid@domain.com”

SELECT

”Return Value” = @return_value

GO’, @database_name=N’HCLDBA’, @flags=0 IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1 IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id=@jobId, @name=N’Detect Config Change’, @enabled=1, @freq_type=4, @freq_interval=1, @freq_subday_type=1, @freq_subday_interval=0, @freq_relative_interval=0, @freq_recurrence_factor=0, @active_start_date=20110817, @active_end_date=99991231, @active_start_time=90000, @active_end_time=235959, @schedule_uid=N’deb2afc2-d84e-47fd-af68-661f550ad5a5′ IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N’(local)’ IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback COMMIT TRANSACTION GOTO EndSave QuitWithRollback: IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION EndSave:

GO