Archive for the ‘PHP’ Category

jquery using confirm box

by on Tuesday, February 21st, 2012

$('.drop-cross-img').live("click", function(){
var cross_img = $(this);
var item_id = cross_img.attr('alt');
var item_tbl = cross_img.attr('rel');
//alert(item_tbl);
var confirmation = confirm('Are you sure, you want to delete it?');
if(confirmation){
jQuery.ajax({
type:'POST',
url: "common/function_outfits.php",
data: "ajax=true&activity=delete_item&itemID="+item_id+"&action="+item_tbl,
success: function(data){
if(data=='Item Deleted.'){
cross_img.parent().remove();
}
}
});
}
});

jquery validationEngine form submit with ajax [Solved]

by on Tuesday, February 21st, 2012

/*
 * Inline Form Validation Engine 1.7, jQuery plugin
 * 
 * Copyright(c) 2010, Cedric Dugas
 * http://www.position-relative.net
 *	
 * Form validation engine allowing custom regex rules to be added.
 * Thanks to Francois Duquette and Teddy Limousin 
 * and everyone helping me find bugs on the forum
 * Licenced under the MIT Licence
 */
$(document).ready(function() {
	// SUCCESS AJAX CALL, replace "success: false," by:     success : function() { callSuccessFunction() }, 
	
	//$("#validate").validationEngine();
	$("#validate1").validationEngine();
	
	$("#validate").validationEngine({
		  ajaxSubmit: true,
		  ajaxSubmitFile: "receive.php",
		  //ajaxSubmitMessage: "We will get back to you with the quote. <br/> Should you require any further assistance, Please contact us on 1800 103 1139 / 09878733999 between 10:00 and 18:30 hours (Monday – Saturday)",
		  //ajaxSubmitExtraData: "securityCode=38709238423&name=john",
		  success : function(res){
			  Popup.showModal('modal33',null,null,{'screenColor':'#000000','screenOpacity':.6});
		  },
		  failure : function() {}  
	  })
});
 
(function($) {
	
	$.fn.validationEngine = function(settings) {
		
	if($.validationEngineLanguage){				// IS THERE A LANGUAGE LOCALISATION ?
		allRules = $.validationEngineLanguage.allRules;
	}else{
		$.validationEngine.debug("Validation engine rules are not loaded check your external file");
	}
 	settings = jQuery.extend({
		allrules:allRules,
		validationEventTriggers:"focusout",					
		inlineValidation: true,	
		returnIsValid:false,
		liveEvent:true,
		unbindEngine:true,
		containerOverflow:false,
		containerOverflowDOM:"",
		ajaxSubmit: false,
		scroll:true,
		promptPosition: "topRight",	// OPENNING BOX POSITION, IMPLEMENTED: topLeft, topRight, bottomLeft, centerRight, bottomRight
		success : false,
		beforeSuccess :  function() {},
		failure : function() {}
	}, settings);	
	$.validationEngine.settings = settings;
	$.validationEngine.ajaxValidArray = new Array();	// ARRAY FOR AJAX: VALIDATION MEMORY 
	
	if(settings.inlineValidation == true){ 		// Validating Inline ?
		if(!settings.returnIsValid){					// NEEDED FOR THE SETTING returnIsValid
			allowReturnIsvalid = false;
			if(settings.liveEvent){						// LIVE event, vast performance improvement over BIND
				$(this).find("[class*=validate][type!=checkbox]").live(settings.validationEventTriggers, function(caller){ _inlinEvent(this);})
				$(this).find("[class*=validate][type=checkbox]").live("click", function(caller){ _inlinEvent(this); })
			}else{
				$(this).find("[class*=validate]").not("[type=checkbox]").bind(settings.validationEventTriggers, function(caller){ _inlinEvent(this); })
				$(this).find("[class*=validate][type=checkbox]").bind("click", function(caller){ _inlinEvent(this); })
			}
			firstvalid = false;
		}
			function _inlinEvent(caller){
				$.validationEngine.settings = settings;
				if($.validationEngine.intercept == false || !$.validationEngine.intercept){		// STOP INLINE VALIDATION THIS TIME ONLY
					$.validationEngine.onSubmitValid=false;
					$.validationEngine.loadValidation(caller); 
				}else{
					$.validationEngine.intercept = false;
				}
			}
	}
	if (settings.returnIsValid){		// Do validation and return true or false, it bypass everything;
		if ($.validationEngine.submitValidation(this,settings)){
			return false;
		}else{
			return true;
		}
	}
	$(this).bind("submit", function(caller){   // ON FORM SUBMIT, CONTROL AJAX FUNCTION IF SPECIFIED ON DOCUMENT READY
		$.validationEngine.onSubmitValid = true;
		$.validationEngine.settings = settings;
		if($.validationEngine.submitValidation(this,settings) == false){
			if($.validationEngine.submitForm(this,settings) == true) return false;
		}else{
			settings.failure && settings.failure(); 
			return false;
		}		
	})
	$(".formError").live("click",function(){	 // REMOVE BOX ON CLICK
		$(this).fadeOut(150,function(){		$(this).remove()	}) 
	})
};	
$.validationEngine = {
	defaultSetting : function(caller) {		// NOT GENERALLY USED, NEEDED FOR THE API, DO NOT TOUCH
		if($.validationEngineLanguage){				
			allRules = $.validationEngineLanguage.allRules;
		}else{
			$.validationEngine.debug("Validation engine rules are not loaded check your external file");
		}	
		settings = {
			allrules:allRules,
			validationEventTriggers:"blur",					
			inlineValidation: true,	
			containerOverflow:false,
			containerOverflowDOM:"",
			returnIsValid:false,
			scroll:true,
			unbindEngine:true,
			ajaxSubmit: false,
			promptPosition: "topRight",	// OPENNING BOX POSITION, IMPLEMENTED: topLeft, topRight, bottomLeft, centerRight, bottomRight
			success : false,
			failure : function() {}
		}	
		$.validationEngine.settings = settings;
	},
	loadValidation : function(caller) {		// GET VALIDATIONS TO BE EXECUTED
		if(!$.validationEngine.settings) $.validationEngine.defaultSetting()
		rulesParsing = $(caller).attr('class');
		rulesRegExp = /\[(.*)\]/;
		getRules = rulesRegExp.exec(rulesParsing);
		if(getRules == null) return false;
		str = getRules[1];
		pattern = /\[|,|\]/;
		result= str.split(pattern);	
		var validateCalll = $.validationEngine.validateCall(caller,result)
		return validateCalll;
	},
	validateCall : function(caller,rules) {	// EXECUTE VALIDATION REQUIRED BY THE USER FOR THIS FIELD
		var promptText =""	
		
		if(!$(caller).attr("id")) $.validationEngine.debug("This field have no ID attribut( name & class displayed): "+$(caller).attr("name")+" "+$(caller).attr("class"))

		caller = caller;
		ajaxValidate = false;
		var callerName = $(caller).attr("name");
		$.validationEngine.isError = false;
		$.validationEngine.showTriangle = true;
		callerType = $(caller).attr("type");

		for (i=0; i<rules.length;i++){
			switch (rules[i]){
			case "optional": 
				if(!$(caller).val()){
					$.validationEngine.closePrompt(caller);
					return $.validationEngine.isError;
				}
			break;
			case "required": 
				_required(caller,rules);
			break;
			case "custom": 
				 _customRegex(caller,rules,i);
			break;
			case "exemptString": 
				 _exemptString(caller,rules,i);
			break;
			case "ajax": 
				if(!$.validationEngine.onSubmitValid) _ajax(caller,rules,i);	
			break;
			case "length": 
				 _length(caller,rules,i);
			break;
			case "maxCheckbox": 
				_maxCheckbox(caller,rules,i);
			 	groupname = $(caller).attr("name");
			 	caller = $("input[name='"+groupname+"']");
			break;
			case "minCheckbox": 
				_minCheckbox(caller,rules,i);
				groupname = $(caller).attr("name");
			 	caller = $("input[name='"+groupname+"']");
			break;
			case "confirm": 
				 _confirm(caller,rules,i);
			break;
			case "funcCall": 
		     	_funcCall(caller,rules,i);
			break;
			default :;
			};
		};
		radioHack();
		if ($.validationEngine.isError == true){
			var linkTofieldText = "." +$.validationEngine.linkTofield(caller);
			if(linkTofieldText != "."){
				if(!$(linkTofieldText)[0]){
					$.validationEngine.buildPrompt(caller,promptText,"error")
				}else{	
					$.validationEngine.updatePromptText(caller,promptText);
				}	
			}else{
				$.validationEngine.updatePromptText(caller,promptText);
			}
		}else{
			$.validationEngine.closePrompt(caller);
		}			
		/* UNFORTUNATE RADIO AND CHECKBOX GROUP HACKS */
		/* As my validation is looping input with id's we need a hack for my validation to understand to group these inputs */
		function radioHack(){
	      if($("input[name='"+callerName+"']").size()> 1 && (callerType == "radio" || callerType == "checkbox")) {        // Hack for radio/checkbox group button, the validation go the first radio/checkbox of the group
	          caller = $("input[name='"+callerName+"'][type!=hidden]:first");     
	          $.validationEngine.showTriangle = false;
	      }      
	    }
		/* VALIDATION FUNCTIONS */
		function _required(caller,rules){   // VALIDATE BLANK FIELD
			callerType = $(caller).attr("type");
			if (callerType == "text" || callerType == "password" || callerType == "textarea"){
								
				if(!$(caller).val()){
					$.validationEngine.isError = true;
					promptText += $.validationEngine.settings.allrules[rules[i]].alertText+"<br />";
				}	
			}	
			if (callerType == "radio" || callerType == "checkbox" ){
				callerName = $(caller).attr("name");
		
				if($("input[name='"+callerName+"']:checked").size() == 0) {
					$.validationEngine.isError = true;
					if($("input[name='"+callerName+"']").size() ==1) {
						promptText += $.validationEngine.settings.allrules[rules[i]].alertTextCheckboxe+"<br />"; 
					}else{
						 promptText += $.validationEngine.settings.allrules[rules[i]].alertTextCheckboxMultiple+"<br />";
					}	
				}
			}	
			if (callerType == "select-one") { // added by paul@kinetek.net for select boxes, Thank you		
				if(!$(caller).val()) {
					$.validationEngine.isError = true;
					promptText += $.validationEngine.settings.allrules[rules[i]].alertText+"<br />";
				}
			}
			if (callerType == "select-multiple") { // added by paul@kinetek.net for select boxes, Thank you	
				if(!$(caller).find("option:selected").val()) {
					$.validationEngine.isError = true;
					promptText += $.validationEngine.settings.allrules[rules[i]].alertText+"<br />";
				}
			}
		}
		function _customRegex(caller,rules,position){		 // VALIDATE REGEX RULES
			customRule = rules[position+1];
			pattern = eval($.validationEngine.settings.allrules[customRule].regex);
			
			if(!pattern.test($(caller).attr('value'))){
				$.validationEngine.isError = true;
				promptText += $.validationEngine.settings.allrules[customRule].alertText+"<br />";
			}
		}
		function _exemptString(caller,rules,position){		 // VALIDATE REGEX RULES
			customString = rules[position+1];
			if(customString == $(caller).attr('value')){
				$.validationEngine.isError = true;
				promptText += $.validationEngine.settings.allrules['required'].alertText+"<br />";
			}
		}
		
		function _funcCall(caller,rules,position){  		// VALIDATE CUSTOM FUNCTIONS OUTSIDE OF THE ENGINE SCOPE
			customRule = rules[position+1];
			funce = $.validationEngine.settings.allrules[customRule].nname;
			
			var fn = window[funce];
			if (typeof(fn) === 'function'){
				var fn_result = fn();
				if(!fn_result){
					$.validationEngine.isError = true;
				}
				
				promptText += $.validationEngine.settings.allrules[customRule].alertText+"<br />";
			}
		}
		function _ajax(caller,rules,position){				 // VALIDATE AJAX RULES
			
			customAjaxRule = rules[position+1];
			postfile = $.validationEngine.settings.allrules[customAjaxRule].file;
			fieldValue = $(caller).val();
			ajaxCaller = caller;
			fieldId = $(caller).attr("id");
			ajaxValidate = true;
			ajaxisError = $.validationEngine.isError;
			
			if($.validationEngine.settings.allrules[customAjaxRule].extraData){
				extraData = $.validationEngine.settings.allrules[customAjaxRule].extraData;
			}else{
				extraData = "";
			}
			/* AJAX VALIDATION HAS ITS OWN UPDATE AND BUILD UNLIKE OTHER RULES */	
			if(!ajaxisError){
				$.ajax({
				   	type: "POST",
				   	url: postfile,
				   	async: true,
				   	data: "validateValue="+fieldValue+"&validateId="+fieldId+"&validateError="+customAjaxRule+"&extraData="+extraData,
				   	beforeSend: function(){		// BUILD A LOADING PROMPT IF LOAD TEXT EXIST		   			
				   		if($.validationEngine.settings.allrules[customAjaxRule].alertTextLoad){
				   		
				   			if(!$("div."+fieldId+"formError")[0]){				   				
	 			 				return $.validationEngine.buildPrompt(ajaxCaller,$.validationEngine.settings.allrules[customAjaxRule].alertTextLoad,"load");
	 			 			}else{
	 			 				$.validationEngine.updatePromptText(ajaxCaller,$.validationEngine.settings.allrules[customAjaxRule].alertTextLoad,"load");
	 			 			}
			   			}
			  	 	},
			  	 	error: function(data,transport){ $.validationEngine.debug("error in the ajax: "+data.status+" "+transport) },
					success: function(data){					// GET SUCCESS DATA RETURN JSON
						data = eval( "("+data+")");				// GET JSON DATA FROM PHP AND PARSE IT
						ajaxisError = data.jsonValidateReturn[2];
						customAjaxRule = data.jsonValidateReturn[1];
						ajaxCaller = $("#"+data.jsonValidateReturn[0])[0];
						fieldId = ajaxCaller;
						ajaxErrorLength = $.validationEngine.ajaxValidArray.length;
						existInarray = false;
						
			 			 if(ajaxisError == "false"){			// DATA FALSE UPDATE PROMPT WITH ERROR;
			 			 	
			 			 	_checkInArray(false)				// Check if ajax validation alreay used on this field
			 			 	
			 			 	if(!existInarray){		 			// Add ajax error to stop submit		 		
				 			 	$.validationEngine.ajaxValidArray[ajaxErrorLength] =  new Array(2);
				 			 	$.validationEngine.ajaxValidArray[ajaxErrorLength][0] = fieldId;
				 			 	$.validationEngine.ajaxValidArray[ajaxErrorLength][1] = false;
				 			 	existInarray = false;
			 			 	}
				
			 			 	$.validationEngine.ajaxValid = false;
							promptText += $.validationEngine.settings.allrules[customAjaxRule].alertText+"<br />";
							$.validationEngine.updatePromptText(ajaxCaller,promptText,"",true);				
						 }else{	 
						 	_checkInArray(true);
						 	$.validationEngine.ajaxValid = true; 			
						 	if(!customAjaxRule)	{$.validationEngine.debug("wrong ajax response, are you on a server or in xampp? if not delete de ajax[ajaxUser] validating rule from your form ")}		   
						 	if($.validationEngine.settings.allrules[customAjaxRule].alertTextOk){	// NO OK TEXT MEAN CLOSE PROMPT	 			
	 			 				 				$.validationEngine.updatePromptText(ajaxCaller,$.validationEngine.settings.allrules[customAjaxRule].alertTextOk,"pass",true);
 			 				}else{
				 			 	ajaxValidate = false;		 	
				 			 	$.validationEngine.closePrompt(ajaxCaller);
 			 				}		
			 			 }
			 			function  _checkInArray(validate){
			 				for(x=0;x<ajaxErrorLength;x++){
			 			 		if($.validationEngine.ajaxValidArray[x][0] == fieldId){
			 			 			$.validationEngine.ajaxValidArray[x][1] = validate;
			 			 			existInarray = true;
			 			 		
			 			 		}
			 			 	}
			 			}
			 		}				
				});
			}
		}
		function _confirm(caller,rules,position){		 // VALIDATE FIELD MATCH
			confirmField = rules[position+1];
			
			if($(caller).attr('value') != $("#"+confirmField).attr('value')){
				$.validationEngine.isError = true;
				promptText += $.validationEngine.settings.allrules["confirm"].alertText+"<br />";
			}
		}
		function _length(caller,rules,position){    	  // VALIDATE LENGTH
		
			startLength = eval(rules[position+1]);
			endLength = eval(rules[position+2]);
			feildLength = $(caller).attr('value').length;

			if(feildLength<startLength || feildLength>endLength){
				$.validationEngine.isError = true;
				promptText += $.validationEngine.settings.allrules["length"].alertText+startLength+$.validationEngine.settings.allrules["length"].alertText2+endLength+$.validationEngine.settings.allrules["length"].alertText3+"<br />"
			}
		}
		function _maxCheckbox(caller,rules,position){  	  // VALIDATE CHECKBOX NUMBER
		
			nbCheck = eval(rules[position+1]);
			groupname = $(caller).attr("name");
			groupSize = $("input[name='"+groupname+"']:checked").size();
			if(groupSize > nbCheck){	
				$.validationEngine.showTriangle = false;
				$.validationEngine.isError = true;
				promptText += $.validationEngine.settings.allrules["maxCheckbox"].alertText+"<br />";
			}
		}
		function _minCheckbox(caller,rules,position){  	  // VALIDATE CHECKBOX NUMBER
		
			nbCheck = eval(rules[position+1]);
			groupname = $(caller).attr("name");
			groupSize = $("input[name='"+groupname+"']:checked").size();
			if(groupSize < nbCheck){	
			
				$.validationEngine.isError = true;
				$.validationEngine.showTriangle = false;
				promptText += $.validationEngine.settings.allrules["minCheckbox"].alertText+" "+nbCheck+" "+$.validationEngine.settings.allrules["minCheckbox"].alertText2+"<br />";
			}
		}
		return ($.validationEngine.isError) ? $.validationEngine.isError : false;
	},
	submitForm : function(caller){
		if($.validationEngine.settings.ajaxSubmit){		
			if($.validationEngine.settings.ajaxSubmitExtraData){
				extraData = $.validationEngine.settings.ajaxSubmitExtraData;
			}else{
				extraData = "";
			}
			$.ajax({
			   	type: "POST",
			   	url: $.validationEngine.settings.ajaxSubmitFile,
			   	async: true,
			   	data: $(caller).serialize()+"&"+extraData,
			   	error: function(data,transport){ $.validationEngine.debug("error in the ajax: "+data.status+" "+transport) },
			   	success: function(data){
			   		if(data == "true"){			// EVERYTING IS FINE, SHOW SUCCESS MESSAGE
			   			$(caller).css("opacity",1)
			   			//$(caller).animate({opacity: 0, height: 0}, function(){
			   				//$(caller).css("display","none");
			   				//$(caller).before("<div class='ajaxSubmit'>"+$.validationEngine.settings.ajaxSubmitMessage+"</div>");
			   				//$.validationEngine.closePrompt(".formError",true); 	
			   				//$(".ajaxSubmit").show("slow");
			   				if ($.validationEngine.settings.success){	// AJAX SUCCESS, STOP THE LOCATION UPDATE
								$.validationEngine.settings.success && $.validationEngine.settings.success(); 
								return false;
							}
			   			//});
						/*setTimeout(
							function(){
								$(caller).css("opacity",1).css("display","block");
								$(".ajaxSubmit").hide("slow");
							}
						,15000);*/
		   			}else{						// HOUSTON WE GOT A PROBLEM (SOMETING IS NOT VALIDATING)
			   			data = eval( "("+data+")");	
			   			if(!data.jsonValidateReturn){
			   				 $.validationEngine.debug("you are not going into the success fonction and jsonValidateReturn return nothing");
			   			}
			   			errorNumber = data.jsonValidateReturn.length	
			   			for(index=0; index<errorNumber; index++){	
			   				fieldId = data.jsonValidateReturn[index][0];
			   				promptError = data.jsonValidateReturn[index][1];
			   				type = data.jsonValidateReturn[index][2];
			   				$.validationEngine.buildPrompt(fieldId,promptError,type);
		   				}
	   				}
   				}
			})	
			return true;
		}
		// LOOK FOR BEFORE SUCCESS METHOD		
			if(!$.validationEngine.settings.beforeSuccess()){
				if ($.validationEngine.settings.success){	// AJAX SUCCESS, STOP THE LOCATION UPDATE
					if($.validationEngine.settings.unbindEngine){ $(caller).unbind("submit") }
					$.validationEngine.settings.success && $.validationEngine.settings.success(); 
					return true;
				}
			}else{
				return true;
			} 
		return false;
	},
	buildPrompt : function(caller,promptText,type,ajaxed) {			// ERROR PROMPT CREATION AND DISPLAY WHEN AN ERROR OCCUR
		if(!$.validationEngine.settings){
			$.validationEngine.defaultSetting()
		}
		deleteItself = "." + $(caller).attr("id") + "formError"
	
		if($(deleteItself)[0]){
			$(deleteItself).stop();
			$(deleteItself).remove();
		}
		var divFormError = document.createElement('div');
		var formErrorContent = document.createElement('div');
		linkTofield = $.validationEngine.linkTofield(caller)
		$(divFormError).addClass("formError")
		
		if(type == "pass") $(divFormError).addClass("greenPopup")
		if(type == "load") $(divFormError).addClass("blackPopup")
		if(ajaxed) $(divFormError).addClass("ajaxed")
		
		$(divFormError).addClass(linkTofield);
		$(formErrorContent).addClass("formErrorContent");
		
		if($.validationEngine.settings.containerOverflow){		// Is the form contained in an overflown container?
			$(caller).before(divFormError);
		}else{
			$("body").append(divFormError);
		}
		
		$(divFormError).append(formErrorContent);
			
		if($.validationEngine.showTriangle != false){		// NO TRIANGLE ON MAX CHECKBOX AND RADIO
			var arrow = document.createElement('div');
			$(arrow).addClass("formErrorArrow");
			$(divFormError).append(arrow);
			if($.validationEngine.settings.promptPosition == "bottomLeft" || $.validationEngine.settings.promptPosition == "bottomRight"){
			$(arrow).addClass("formErrorArrowBottom")
			$(arrow).html('<div class="line1"><!-- --></div><div class="line2"><!-- --></div><div class="line3"><!-- --></div><div class="line4"><!-- --></div><div class="line5"><!-- --></div><div class="line6"><!-- --></div><div class="line7"><!-- --></div><div class="line8"><!-- --></div><div class="line9"><!-- --></div><div class="line10"><!-- --></div>');
		}
			if($.validationEngine.settings.promptPosition == "topLeft" || $.validationEngine.settings.promptPosition == "topRight"){
				$(divFormError).append(arrow);
				$(arrow).html('<div class="line10"><!-- --></div><div class="line9"><!-- --></div><div class="line8"><!-- --></div><div class="line7"><!-- --></div><div class="line6"><!-- --></div><div class="line5"><!-- --></div><div class="line4"><!-- --></div><div class="line3"><!-- --></div><div class="line2"><!-- --></div><div class="line1"><!-- --></div>');
			}
		}
		$(formErrorContent).html(promptText)
		
		var calculatedPosition = $.validationEngine.calculatePosition(caller,promptText,type,ajaxed,divFormError)
		
		calculatedPosition.callerTopPosition +="px";
		calculatedPosition.callerleftPosition +="px";
		calculatedPosition.marginTopSize +="px"
		$(divFormError).css({
			"top":calculatedPosition.callerTopPosition,
			"left":calculatedPosition.callerleftPosition,
			"marginTop":calculatedPosition.marginTopSize,
			"opacity":0
		})
		return $(divFormError).animate({"opacity":0.87},function(){return true;});	
	},
	updatePromptText : function(caller,promptText,type,ajaxed) {	// UPDATE TEXT ERROR IF AN ERROR IS ALREADY DISPLAYED
		
		linkTofield = $.validationEngine.linkTofield(caller);
		var updateThisPrompt =  "."+linkTofield;
		
		if(type == "pass") { $(updateThisPrompt).addClass("greenPopup") }else{ $(updateThisPrompt).removeClass("greenPopup")};
		if(type == "load") { $(updateThisPrompt).addClass("blackPopup") }else{ $(updateThisPrompt).removeClass("blackPopup")};
		if(ajaxed) { $(updateThisPrompt).addClass("ajaxed") }else{ $(updateThisPrompt).removeClass("ajaxed")};
	
		$(updateThisPrompt).find(".formErrorContent").html(promptText);
		
		var calculatedPosition = $.validationEngine.calculatePosition(caller,promptText,type,ajaxed,updateThisPrompt)
		
		calculatedPosition.callerTopPosition +="px";
		calculatedPosition.callerleftPosition +="px";
		calculatedPosition.marginTopSize +="px"
		$(updateThisPrompt).animate({ "top":calculatedPosition.callerTopPosition,"marginTop":calculatedPosition.marginTopSize });
	},
	calculatePosition : function(caller,promptText,type,ajaxed,divFormError){
		
		if($.validationEngine.settings.containerOverflow){		// Is the form contained in an overflown container?
			callerTopPosition = 0;
			callerleftPosition = 0;
			callerWidth =  $(caller).width();
			inputHeight = $(divFormError).height();					// compasation for the triangle
			var marginTopSize = "-"+inputHeight;
		}else{
			callerTopPosition = $(caller).offset().top;
			callerleftPosition = $(caller).offset().left;
			callerWidth =  $(caller).width();
			inputHeight = $(divFormError).height();
			var marginTopSize = 0;
		}
		
		/* POSITIONNING */
		if($.validationEngine.settings.promptPosition == "topRight"){ 
			if($.validationEngine.settings.containerOverflow){		// Is the form contained in an overflown container?
				callerleftPosition += callerWidth -30;
			}else{
				callerleftPosition +=  callerWidth -30; 
				callerTopPosition += -inputHeight; 
			}
		}
		if($.validationEngine.settings.promptPosition == "topLeft"){ callerTopPosition += -inputHeight -10; }
		
		if($.validationEngine.settings.promptPosition == "centerRight"){ callerleftPosition +=  callerWidth +13; }
		
		if($.validationEngine.settings.promptPosition == "bottomLeft"){
			callerHeight =  $(caller).height();
			callerTopPosition = callerTopPosition + callerHeight + 15;
		}
		if($.validationEngine.settings.promptPosition == "bottomRight"){
			callerHeight =  $(caller).height();
			callerleftPosition +=  callerWidth -30;
			callerTopPosition +=  callerHeight +5;
		}
		return {
			"callerTopPosition":callerTopPosition,
			"callerleftPosition":callerleftPosition,
			"marginTopSize":marginTopSize
		}
	},
	linkTofield : function(caller){
		var linkTofield = $(caller).attr("id") + "formError";
		linkTofield = linkTofield.replace(/\[/g,""); 
		linkTofield = linkTofield.replace(/\]/g,"");
		return linkTofield;
	},
	closePrompt : function(caller,outside) {						// CLOSE PROMPT WHEN ERROR CORRECTED
		if(!$.validationEngine.settings){
			$.validationEngine.defaultSetting()
		}
		if(outside){
			$(caller).fadeTo("fast",0,function(){
				$(caller).remove();
			});
			return false;
		}
		if(typeof(ajaxValidate)=='undefined'){ajaxValidate = false}
		if(!ajaxValidate){
			linkTofield = $.validationEngine.linkTofield(caller);
			closingPrompt = "."+linkTofield;
			$(closingPrompt).fadeTo("fast",0,function(){
				$(closingPrompt).remove();
			});
		}
	},
	debug : function(error) {
		if(!$("#debugMode")[0]){
			$("body").append("<div id='debugMode'><div class='debugError'><strong>This is a debug mode, you got a problem with your form, it will try to help you, refresh when you think you nailed down the problem</strong></div></div>");
		}
		$(".debugError").append("<div class='debugerror'>"+error+"</div>");
	},			
	submitValidation : function(caller) {					// FORM SUBMIT VALIDATION LOOPING INLINE VALIDATION
		var stopForm = false;
		$.validationEngine.ajaxValid = true;
		var toValidateSize = $(caller).find("[class*=validate]").size();
		
		$(caller).find("[class*=validate]").each(function(){
			linkTofield = $.validationEngine.linkTofield(this);
			
			if(!$("."+linkTofield).hasClass("ajaxed")){	// DO NOT UPDATE ALREADY AJAXED FIELDS (only happen if no normal errors, don't worry)
				var validationPass = $.validationEngine.loadValidation(this);
				return(validationPass) ? stopForm = true : "";					
			};
		});
		ajaxErrorLength = $.validationEngine.ajaxValidArray.length;		// LOOK IF SOME AJAX IS NOT VALIDATE
		for(x=0;x<ajaxErrorLength;x++){
	 		if($.validationEngine.ajaxValidArray[x][1] == false) $.validationEngine.ajaxValid = false;
 		}
		if(stopForm || !$.validationEngine.ajaxValid){		// GET IF THERE IS AN ERROR OR NOT FROM THIS VALIDATION FUNCTIONS
			if($.validationEngine.settings.scroll){
				if(!$.validationEngine.settings.containerOverflow){
					var destination = $(".formError:not('.greenPopup'):first").offset().top;
					$(".formError:not('.greenPopup')").each(function(){
						testDestination = $(this).offset().top;
						if(destination>testDestination) destination = $(this).offset().top;
					})
					$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100);
				}else{
					var destination = $(".formError:not('.greenPopup'):first").offset().top;
					var scrollContainerScroll = $($.validationEngine.settings.containerOverflowDOM).scrollTop();
					var scrollContainerPos = - parseInt($($.validationEngine.settings.containerOverflowDOM).offset().top);
					var destination = scrollContainerScroll + destination + scrollContainerPos -5
					var scrollContainer = $.validationEngine.settings.containerOverflowDOM+":not(:animated)"
					
					$(scrollContainer).animate({ scrollTop: destination}, 1100);
				}
			}
			return true;
		}else{
			return false;
		}
	}
}
})(jQuery);

Simple viewer flickr

by on Monday, February 20th, 2012

This site automatically publishes the images of this set in my Flickr album, without any manual intervention on my part.

Ready to create your own? Here we go:

1 ° / Find a host

To host your site, you need a server.

If you want to use a free hosting, you can opt for Free, by following the indications of this article (How to create a free website at free.fr).

You can also opt for a hébergment paid for 10 or € 20 per year, for example at OVH at NFrance or 1 & 1.

Warning: you need the fopen function is activated on your server. Imperative to ask your provider if this feature is active on the accommodation you want to!
(if you have a free hosting on Free, this feature is enabled).

I will soon publish a way to circumvent this by changing the script, for those not on their server fopen (using cURL, for those who know).

It is not worth to take shelter with mysql database, you will not need in the case of the site that we create.

Your web space is functional? So go on …

2 ° / Equip yourself some free software

We will need three programs:

– A text editor to modify some files on the site.
The Windows notepad will do quite the case, or any other text editor of database you have on your computer.

– An FTP client to upload the files on your web server.
In this tutorial, we will use Filezilla, which is free and simple to use.

– A software to create your logo, for example Gimp or Inkscape.
It is not essential, but you’ll need if you want to create a logo for your site.

3 ° / Prepare files

1 – Download scripts

We will download the SimpleViewer FlickrViewer and which are free scripts that will be needed:

Download SimpleViewer 1.7
(watch, download this version and not another, otherwise it will not work).

Download FlickrViewer 1.1

2 – Preparation of files

– Unpack the downloaded archive (SimpleViewer and FlickrViewer) on your desktop for example.

– Open the folder SimpleViewer, and replace the file “index.html” with the file “index.html” that is contained in the archive FlickrViewer.

– Take the “flickrViewer.php” that is contained in the archive FlickrViewer and place it in the SimpleViewer.

There. SimpleViewer folder now contains everything we need.
We still have to set some preferences before sending it on the web server.

3 – Get a key to use the Flickr API

For your site to connect to Flickr, you need an API key.

Nothing complicated in there, just go to this address once you’ve logged into your Flickr account and follow these instructions:

Flickr needs to know who we are and for what purpose we wish to use from our Flickr site.

– We will complete the form by providing a name and an e-mail.

– Then, select “non-commercial use.

– In the “Describe the application you are planning to build, we will explain to Flickr what we want to make the API.
For example, copy the following:
Quote:
I need to have an API key to make use of the Flickr API with SimpleViewer and FlickrViewer (weeting.org / mark / flickrviewer /) on my website (address of your site here).
– We check the two boxes at the bottom to accept the terms of use, and valid.

– On the next page, a beautiful code looks: he is our precious key without which the site will not be able to access Flickr.
On the copy, and keeps carefully.

4 – Set Preferences

With Notepad or any text editor, open the file flickrViewer.php (which is now in the SimpleViewer).

We will now change a few things:

1 – Change the key:

Line 22, you have this:
Quote:
$ apikey = ‘b4bb27c883f06aa4575c6c346c402749’;
Replace b4bb27c883f06aa4575c6c346c402749 your API key obtained above.
Make sure you keep the quotes around the key.

2 – Change the identifier of the set

Your site will not display all photos in your Flickr album, but only those of a particular set (one set on Flickr is a category of your album).

For example, you can create a set “Best of”, containing your favorite photos, which will also be published on your site.
Info: On Flickr, a photo can be placed in several sets.

If you have not created a set in your Flickr account, go to Flickr, go to “Organize> Your Sets” and click “create a new set at the top of the screen.
Drag a thumbnail in the case of the image at the top, and choose a name for your set.

Recover indentify the set:
Going on the main page of the set we choose.
For example, in my case: Romania (best) – a photoset on Flickr
The identifier of the set is simply the numbers that are at the end of this address, namely 72157594533186826 in my case.
Search this identifier, and write it down.

Now back to our text editor:
Line 65, you have this:
Quote:
$ setId =’72057594052387557 ‘;
72057594052387557 replace the identifier set, we have noted in the previous step.
Make sure you keep the quotes around that figure.

3 – Change the address of the Flickr album

Line 74, we have this:
Quote:
$ userurl = ‘http://www.flickr.com/photos/markymoo/’;
Replace your ID markymoo by Flickr.
Make sure you keep the “/” final and apostrophes.

4 – Definition of the temporary file

FlickrViewer needs a place where it can create a temporary file to store information.
This allows the site to be faster: it will not need to question when Flickr will have the requested information in memory.

Line 83, we have this:
Quote:
$ cache = “/ tmp / flickr.xml”;
Some shared servers (= accounts of public accommodation), do not write in / tmp of the server, for security reasons.

We will therefore create a specific folder, which we will give rights to write to store this temporary file.

To do this:

1 – open the software filezilla

2 – enter in the top bar of the Filezilla FTP connection information provided by our host.
In the case “port”, to 21.
Then click on “fast”.

3 – Create a folder for the temporary file:
In the right box, we can explore our hosting space.
We will go into the folder that contains the site (for example the folder “www”, this depends on your host) and with a right click, choose “create a directory”.
Call this directory “tmp”.

4 – Give rights to write to this directory.
To allow the site to save temporary files in the directory you just created:
– Let’s do this right click on new folder “tmp”
– Click “File attributes”
– In “value”, enter 777
This will open all access rights on this file.
Then validate.

Now back to our text editor:
Line 83, we have this:
Quote:
$ cache = “/ tmp / flickr.xml”;
We will simply remove the first “/” symbol to denote the tmp folder that is not the server root, but in our personal files to us
This gives:
Quote:
$ cache = “tmp / flickr.xml”;
(we simply removed the first “/”.)

5 – Choose Preferences:

– Hours Cache:

Line 102, we have this:
Quote:
$ ttl = 43200;
This corresponds to the period during which photographs are stored in memory (in the temporary folder that you just created ), In seconds.
Over this period is long, unless your site will have to use Flickr to go look for information.
But also, less your site will be updated regularly.

43200 seconds is 12 hours is a good choice. But you can change this value (0 = nothing is stored in memory.

– Title of site:

Line 107, we have this:
Quote:
$ title = “My Favorite Photos”;
Replace with the title of your site, in keeping with the quotation marks around it.

– Link to Flickr:

Line 120, we have this:
Quote:
$ showImageLink = true;
If you let true, then a link to the Flickr page containing the image will be placed on your site.
If you do not want to replace true by false

– Title of images:

Line 132, we have this:
Quote:
$ showImageCaption = true;
Let true if you want to display the title of the image (taken from Flickr), or make false if you do not wish to.

– Translation of the link that points to the Flickr page:

If you chose to display the link to the photo on Flickr (see step “link to flickr”, line 286 Replace the text
“View full size …”
by: “View actual size” or “See my album on Flickr or whatever you want. This is the text that appears on this link.

– Configuration page:

In your text editor, open the index.html file:

Line 5, you have this:
Quote:
SimpleViewer / Flickr interface in PHP
Replace with the title of your page, it will appear in the top bar of the browser (do not delete the title tags, simply change the text between the tags).

For those knowledgeable in html:
If you want to add a logo, text, links … It is also here that it happens.
You can add your content (logo, text, links …) between the body tags. The part between the tags is the script display images.
You can change the placement of the viewer by changing the style sheet included in the file index.html.

6 – is sent on the server!

First record of the files that we modified.

With Filezilla, then send the contents of the SimpleViewer folder on your web server.

(In the right pane, view the folder of your website, and from the left window, drag the files in the folder SimpleViewer towards the right window).

Add Lumis Gallery to your site

by on Monday, February 20th, 2012

The advantage of Lumis Gallery, is to propose a solution:

– All your Flickr sets are taken into account
– Comments are displayed directly on your site
– You also get a “blog” automatic, which displays the descriptions of your Flickr account you choose
– You have a page with a map of the world where you can see your photos geolocation

The disadvantage: your site is in English.
Yet it was a plus for those who want to do their work outside the Francophone world, without having the control necessary to design their own site in English.

1. Demonstration

Here is how your site if you follow this tutorial:

– Example home page (see the list of sets on the right, the effect in mouse …)

– Example of a display set

– Example of displaying a photo (see posting comments below)

2. Prerequisites

– Have an account on Flickr and use it.
Flickr is a site for sharing pictures easy to use. A comprehensive tutorial on using the service is available here (to make themselves known through Flickr: The user guide).

– Having a web hosting with mysql database.

3. Installation

– Download Lumis Gallery here.

– Unpack the archive on your PC.

– Inc_config.php Open the file in a text editor (Notepad …)

– In this file, make the following replacements:

– Line 12 ($ approot), enter the address where your site is available.

– Line 15 ($ FlickrAPIkey), enter your key to the Flickr API:

For your site to connect to Flickr, you need an API key.

Nothing complicated in there, just go to this address once you’ve logged into your Flickr account and follow these instructions:

Flickr needs to know who we are and for what purpose we wish to use from our Flickr site.

– We will complete the form by providing a name and an e-mail.

– Then, select “non-commercial use.

– In the “Describe the application you are planning to build, we will explain to Flickr what we want to make the API.
For example, copy the following:
Quote:
I need to have an API key to make use of the Flickr API with Lumis Gallery (lumis.com / lumisGallery /) on my website (address of your site here).
– We check the two boxes at the bottom to accept the terms of use, and valid.

– On the next page, a beautiful code looks: he is our precious key without which the site will not be able to access Flickr.
On the copy, and keeps carefully.

– Line 19 ($ gMapsApi): enter your API key for Google Map.

This key is used to display the world map to locate your photos, using the Google Map.

To get it, is simple:

– Go here

– At the bottom, select the check box and enter the address of your site.

– On the next page, the key appears below the text “Your key is”.

Copy it and paste it in your file.

– Line 23 ($ defaultUser), enter your Flickr username.
(Go here if you have not yet defined).

– Fill out the information in your mysql database:

This information is provided by your host:
– Line 31 ($ cachedbUsername): the identifier to access the mysql database
– Line 33 ($ cachedbpassword): the password to access the mysql database
– Line 35 ($ cachedbserver): mysql host (usually: localhost)
– Line 37 ($ cachedb): The name of the mysql database

– The rest of the file can be left unchanged.

However, if you want to change some options (number of images per page, etc …), in which case you should change the other variables.

– Save the file, then send the contents of the folder on your server, eg Filezilla (Learn how to use Filezilla).

4. Use Lumis Gallery

– Location of pages:

Your home page is available here: monsite.com / pictures.php

Another type of home page is available here (list of sets): monsite.com / sets.php? / Viewall /

The blog is available here: monsite.com / tblog.php? / Page1 /

The card for GSE is available here: monsite.com / map.php

– Use of the blog:

The blog displays descriptions of photos that you put a specific tag in Flickr.

This tag is as follows: lumisGallery: blog =*
(replace the * with a category name to be created automatically on your blog).

Nothing more to do!

– Using the card geolocation:

It is fully automatic. Just tagged photos to your Flickr account (see tutorial here (to make themselves known through Flickr: The user guide)).

– If you want the home page is displayed directly chosen when entering the address of the site:

If your server has mod rewrite enabled (ask your host), create a file where you specify:

Quote:
RewriteEngine on
RewriteRule ^ index.html $ pictures.php
(change pictures.php the page you want to host the site).

Name this file. Htaccess (with a. Before) and place it at the root of the site.

– Customize the design of your site:

To personalize the top of the page: edit inc_header.php
To customize the bottom of the page: edit inc_footer.php
To change the CSS styles: edit lumisGallery.css

Get Lat Long on google map

by on Monday, February 20th, 2012

You can get the latitude and longitude of any location on google map by just clicking on that location. Check this out:
But please make sure you have your own google api..

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″/>
<title>
Google Visualization API Sample
</title>
<!–<script type=”text/javascript” src=”http://www.google.com/jsapi”></script>–>
<script src=”http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA_pv6r9wQUcY29kuVsKu_WRQNER5ay7E813Acg9jrQ4QegGSv

oxQtPvukQA-F6gkLXexTdocP127B3g” type=”text/javascript”></script>

<script type=”text/javascript”>

//<![CDATA[
var marca;
var latinput;
var loninput;
var mapleveli;
testing = function load() {
if (GBrowserIsCompatible()) {

var map = new GMap2(document.getElementById(“map”));
//map.setCenter(new GLatLng(8.984868485653589, -79.51179027557373), 15);
map.setCenter(new GLatLng(37.4419, -122.1419), 15);
var point = new GLatLng(37.4419, -122.1419);

map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());

latinput=document.getElementById(“latinput”);
loninput=document.getElementById(“loninput”);
mapleveli=document.getElementById(“maplevel”);

GEvent.addListener(map,”click”, function(overlay,point) {
//alert(point.x+” “+point.y);
//alert(point);
if(marca){
marca.hide();
marca=new GMarker(point,{“clickable”:false});
map.addOverlay(marca);
latinput.value=point.y;
loninput.value=point.x;
mapleveli.value=map.getZoom()
}
else{
marca=new GMarker(point,{“clickable”:false});
map.addOverlay(marca);
latinput.value=point.y;
loninput.value=point.x;
mapleveli.value=map.getZoom()
}
});
}
}
window.onload=testing;
//]]>
</script>
</head>
<body style=”font-family: Arial;border: 0 none;”>

<label>Property Map Location</label>
<div id=”map” style=”width: 920px; height: 500px”>Loading…</div>

Latitude: <input name=”data[Property][latitude]” id=”latinput” value=”8.984868485653589″>
Longitude: <input name=”data[Property][longitude]” id=”loninput” value=”-79.51179027557373″>
Map level <input name=”data[Property][maplevel]” id=”maplevel” value=”15″>

</body>
</html>

[solved] Mailer Error: Could not instantiate mail function

by on Monday, February 20th, 2012

Error is:
Test emails work fine and so do small batches, but full lists (50+ users) report the following error in the eventlog shortly after queueing a batch:

Quote:
Mailer Error: Could not instantiate mail function

The Reason:

Bluehost limits email to 50 messages per hour by default. Once this limit has been exceeded, the above error is produced in the PHPlist eventlog after each individual message is sent. You can verify this by looking at your server error logs; it will likely state that the hourly email limit has been reached.

The Solution:

You’ve got two choices:

Throttle your email below the acceptable limit (50/hour). Keep in mind that your regular email traffic must be considered as well. If you send 50 list messages per hour, you won’t be able to send your normal email for another hour either.

The other solution is to contact Bluehost and request that the limit be increased–there’s no guarantee that they will, but it could be worth a try. Don’t bother doing this if you are using PHPList to spam unsolicited messages–it will just get your account terminated.

Although my experience with this issue has been limited to Bluehost, there’s no reason why this error wouldn’t apply to other hosts. When in doubt, check your server’s error logs for more details.

Login admin problem Magento on localhost

by on Monday, February 20th, 2012

Sometime magento generate a problem with admin login. Not so worry follow me:

go to here: \magento\app\code\core\Mage\Core\Model\Session\Abstract
and open Varien.php file.
Now comment the three lines from like this:

// session cookie params
$cookieParams = array(
‘lifetime’ => $cookie->getLifetime(),
‘path’ => $cookie->getPath(),
/* ‘domain’ => $cookie->getConfigDomain(),
‘secure’ => $cookie->isSecure(),
‘httponly’ => $cookie->getHttponly() */
);

and try to login again to admin.

I hope its work for you.

Adding virtual host wamp server windows xp

by on Monday, February 20th, 2012

here is the solution:
open:
c:\wamp\apache\apache2.2.8\bin\conf\httpd.conf

add this at the end of this file

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot “e:/testsite/”
ServerName testsite
</VirtualHost>
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot “e:/”
ServerName localhost
</VirtualHost>

and now open:
C:\WINDOWS\system32\drivers\etc\hosts

add this at the end
127.0.0.1 localhost
127.0.0.1 testsite

and you can use your testsite using
http://testsite and other projects you can open normal like this:
http://localhost

INTERVIEW QUESTIONS PART 2

by on Monday, February 20th, 2012

Q:1 What are the differences between Get and post methods in form submitting.
give the case where we can use get and we can use post methods?
A:1

When to use GET or POST

The HTML 2.0 specification says, in section Form
Submission (and the HTML 4.0 specification repeats this with minor
stylistic changes):

–>If the processing of a form is idempotent
(i.e. it has no lasting observable effect on the state of the
world), then the form method should be GET. Many database searches
have no visible side-effects and make ideal applications of query
forms.

–>If the service associated with the processing of a form has side
effects (for example, modification of a database or subscription to
a service), the method should be POST.

How the form data is transmitted?

quotation from the HTML 4.0 specification

–> If the method is “get” – -, the user agent
takes the value of action, appends a ? to it, then appends the form
data set, encoded using the application/x-www-form-urlencoded
content type. The user agent then traverses the link to this URI. In
this scenario, form data are restricted to ASCII codes.
–> If the method is “post” –, the user agent conducts an HTTP post
transaction using the value of the action attribute and a message
created according to the content type specified by the enctype
attribute.

Quote from CGI FAQ

Firstly, the the HTTP protocol specifies
differing usages for the two methods. GET requests should always be
idempotent on the server. This means that whereas one GET request
might (rarely) change some state on the Server, two or more
identical requests will have no further effect.

This is a theoretical point which is also good
advice in practice. If a user hits “reload” on his/her browser, an
identical request will be sent to the server, potentially resulting
in two identical database or
guestbook entries, counter increments, etc. Browsers may reload a
GET URL automatically, particularly if cacheing is disabled (as is
usually the case with CGI output), but will typically prompt the
user before
re-submitting a POST request. This means you’re far less likely to
get inadvertently-repeated entries from POST.

GET is (in theory) the preferred method for
idempotent operations, such as querying a database, though it
matters little if you’re using a form. There is a further practical
constraint that many systems have built-in limits to the length of a
GET request they can handle: when the total size of a request (URL+params)
approaches or exceeds 1Kb, you are well-advised to use POST in any
case.

I would prefer POST when I don’t want the status to
be change when user resubmits. And GET
when it does not matter.

Q:2 Who is the father of PHP and explain the changes in PHP versions?
A:2 Rasmus Lerdorf is known as the father of PHP.PHP/FI 2.0 is an early and no longer supported version of PHP. PHP 3
is the successor to PHP/FI 2.0 and is a lot nicer. PHP 4 is the current
generation of PHP, which uses the
Zend engine
under the
hood. PHP 5 uses
Zend engine 2 which,
among other things, offers many additionalOOP features
Q:3 How can we submit a form without a submit button?
A:3 The main idea behind this is to use Java script submit() function in
order to submit the form without explicitly clicking any submit button.
You can attach the document.formname.submit() method to onclick,
onchange events of different inputs and perform the form submission. you
can even built a timer function where you can automatically submit the
form after xx seconds once the loading is done (can be seen in online
test sites).
Q:4 In how many ways we can retrieve the data in the result set of
MySQL using PHP?
A:4 You can do it by 4 Ways1. mysql_fetch_row.
2. mysql_fetch_array
3. mysql_fetch_object
4. mysql_fetch_assoc
Q:5 What is the difference between mysql_fetch_object and
mysql_fetch_array?
A:5 mysql_fetch_object() is similar tomysql_fetch_array(), with one difference –
an object is returned, instead of an array. Indirectly, that means that
you can only access the data by the field names, and not by their
offsets (numbers are illegal property names).
Q:6 What is the difference between $message and $$message?
A:6 It is a classic example of PHP’s variable variables. take the
following example.$message = “Mizan”;$$message = “is a moderator of PHPXperts.”;$message is a simple PHP variable that we are used to. But the
$$message is not a very familiar face. It creates a variable name $mizan
with the value “is a moderator of PHPXperts.” assigned. break it like
this${$message} => $mizanSometimes it is convenient to be able to have variable variable
names. That is, a variable name which can be set and used dynamically.
Q:7 How can we extract string ‘abc.com ‘ from a string ‘http://info@abc.com’
using regular expression of PHP?
A:7 preg_match(”/^http:\/\/.+@(.+)$/”,’http://info@abc.com’,$found);
echo $found[1];
Q:8 How can we create a database using PHP and MySQL?
A:8 We can create MySQL database with the use of
mysql_create_db(“Database Name”)
Q:9 What are the differences between require and include,
include_once and require_once?
A:9 The include() statement includes
and evaluates the specified file.The documentation below also applies to
require(). The two constructs
are identical in every way except how they handle
failure. include() produces a
Warning while require() results
in a Fatal Error. In other words, use
require() if you want a missing
file to halt processing of the page. 
include()
 does not behave this way, the script will
continue regardless.

The include_once()
statement includes and evaluates the
specified file during the execution of
the script. This is a behavior similar
to the include()
statement, with the only difference
being that if the code from a file has
already been included, it will not be
included again. As the name suggests, it
will be included just once.include_once()
should be used in cases where the same
file might be included and evaluated
more than once during a particular
execution of a script, and you want to
be sure that it is included exactly once
to avoid problems with function
redefinitions, variable value
reassignments, etc.

require_once()
should be used in cases where the same
file might be included and evaluated
more than once during a particular
execution of a script, and you want to
be sure that it is included exactly once
to avoid problems with function
redefinitions, variable value
reassignments, etc.

Q:10 Can we use include (”abc.PHP”) two times in a PHP page “makeit.PHP”?
A:10 Yes we can use include() more than one time in any page though it is
not a very good practice.
Q:11 What are the different tables present in MySQL, which type of
table is generated when we are creating a table in the following syntax:
create table employee (eno int(2),ename varchar(10)) ?
A:11 Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. INNO DB
5. ISAM
MyISAM is the default storage engine as of MySQL 3.23 and as a result if
we do not specify the table name explicitly it will be assigned to the
default engine.
Q:12 Functions in IMAP, POP3 AND LDAP?
A:12 You can find these specific information in PHP Manual.
Q:13 How can I execute a PHP script using command line?
A:13 As of version 4.3.0, PHP supports a new SAPI type (Server
Application Programming Interface) named CLI which means Command Line
Interface. Just run the PHP CLI (Command Line Interface) program and
provide the PHP script file name as the command line argument. For
example, “php myScript.php”, assuming “php” is the command to invoke the
CLI program.
Be aware that if your PHP script was written for the Web CGI interface,
it may not execute properly in command line environment.
Q:14 Suppose your Zend engine supports the mode Then how can u
configure your PHP Zend engine to support mode ?
A:14 In php.ini file:
set
short_open_tag=on
to make PHP support
Q:15 Shopping cart online validation i.e. how can we configure Paypal,
etc.?
A:15 We can find the detail documentation about different paypal
integration process at the following site

PAYPAL PHP
SDK : HTTP://WWW.PAYPALDEV.ORG

Q:16 What is meant by nl2br()?
A:16 Inserts HTML line breaks (
before all newlines in a string
string nl2br (string); Returns string with ” inserted before all
newlines. For example: echo nl2br(”god bless\n you”) will output “god
bless
you” to your browser.
Q:17 Draw the architecture of Zend engine?
A:17 The Zend Engine is the internal compiler and runtime engine used by
PHP4. Developed by Zeev Suraski and Andi Gutmans, the Zend Engine is an
abbreviation of their names. In the early days of PHP4, it worked as
follows:
The PHP script was loaded by the Zend Engine and compiled into Zend
opcode. Opcodes, short for operation codes, are low level binary
instructions. Then the opcode was executed and the HTML generated sent
to the client. The opcode was flushed from memory after execution.Today, there are a multitude of products and techniques to help you
speed up this process. In the following diagram, we show the how modern
PHP scripts work; all the shaded boxes are optional.
PHP Scripts are loaded into memory and compiled into Zend opcodes.
Q:18 What are the current versions of apache, PHP, and MySQL?
A:18 As of February, 2007 the current versions arePHP: php5.2.1
MySQL: MySQL 5.2
Apache: Apache 2.2.4Note: visit www.php.net,

http://dev.mysql.com/downloads/mysql/
,
www.apache.org to get current
versions.
Q:19 What are the reasons for selecting lamp (Linux, apache, MySQL,
PHP) instead of combination of other software programs, servers and
operating systems?
A:19 All of those are open source resource. Security of Linux is very
very more than windows. Apache is a better server that IIS both in
functionality and security. MySQL is world most popular open source
database. PHP is more faster that asp or any other scripting language.
Q:20 How can we encrypt and decrypt a data present in a MySQL table
using MySQL?
A:20 AES_ENCRYPT () and AES_DECRYPT ()
Q:21 How can we encrypt the username and password using PHP?
A:21 The functions in this section perform encryption and decryption, and
compression and uncompression:

encryption decryption
AES_ENCRYT() AES_DECRYPT()
ENCODE() DECODE()
DES_ENCRYPT() DES_DECRYPT()
ENCRYPT() Not available
MD5() Not available
OLD_PASSWORD() Not available
PASSWORD() Not available
SHA() or SHA1() Not available
Not available UNCOMPRESSED_LENGTH()

 

Q:22 What are the features and advantages of object-oriented
programming?
A:22 One of the main advantages of OO programming is its ease of
modification; objects can easily be modified and added to a system there
by reducing maintenance costs. OO programming is also considered to be
better at modeling the real world than is procedural programming. It
allows for more complicated and flexible interactions. OO systems are
also easier for non-technical personnel to understand and easier for
them to participate in the maintenance and enhancement of a system
because it appeals to natural human cognition patterns.
For some systems, an OO approach can speed development time since many
objects are standard across systems and can be reused. Components that
manage dates, shipping, shopping carts, etc. can be purchased and easily
modified for a specific system
Q:23 What are the differences between procedure-oriented languages and
object-oriented languages?
A:23 Traditional programming has the following characteristics:Functions are written sequentially, so that a change in programming can
affect any code that follows it.
If a function is used multiple times in a system (i.e., a piece of code
that manages the date), it is often simply cut and pasted into each
program (i.e., a change log, order function, fulfillment system, etc).
If a date change is needed (i.e., Y2K when the code needed to be changed
to handle four numerical digits instead of two), all these pieces of
code must be found, modified, and tested.
Code (sequences of computer instructions) and data (information on which
the instructions operates on) are kept separate. Multiple sets of code
can access and modify one set of data. One set of code may rely on data
in multiple places. Multiple sets of code and data are required to work
together. Changes made to any of the code sets and data sets can cause
problems through out the system.Object-Oriented programming takes a radically different approach:Code and data are merged into one indivisible item – an object (the
term “component” has also been used to describe an object.) An object is
an abstraction of a set of real-world things (for example, an object may
be created around “date”) The object would contain all information and
functionality for that thing (A date
object it may contain labels like January, February, Tuesday, Wednesday.
It may contain functionality that manages leap years, determines if it
is a business day or a holiday, etc., See Fig. 1). Ideally, information
about a particular thing should reside in only one place in a system.
The information within an object is encapsulated (or hidden) from the
rest of the system.
A system is composed of multiple objects (i.e., date function, reports,
order processing, etc., See Fig 2). When one object needs information
from another object, a request is sent asking for specific information.
(for example, a report object may need to know what today’s date is and
will send a request to the date object) These requests are called
messages and each object has an interface that manages messages.
OO programming languages include features such as “class”, “instance”,
“inheritance”, and “polymorphism” that increase the power and
flexibility of an object.
Q:24 What is the use of friend function?
A:24 Sometimes a function is best shared among a number of different
classes. Such functions can be declared either as member functions of
one class or as global functions. In either case they can be set to be
friends of other classes, by using a friend specifier in the class that
is admitting them. Such functions can use all attributes of the class
which names them as a friend, as if they were themselves members of that
class.
A friend declaration is essentially a prototype for a member function,
but instead of requiring an implementation with the name of that class
attached by the double colon syntax, a global function or member
function of another class provides the match.
Q:25 What are the differences between public, private, protected,
static, transient, final and volatile?
A:25 Public: Public declared items can be accessed everywhere.
Protected: Protected limits access to inherited and parent
classes (and to the class that defines the item).
Private: Private limits visibility only to the class that defines
the item.
Static: A static variable exists only in a local function scope,
but it does not lose its value when program execution leaves this scope.
Final: Final keyword prevents child classes from overriding a
method by prefixing the definition with final. If the class itself is
being defined final then it cannot be extended.
transient: A transient variable is a variable that may not
be serialized. 
volatile:
 a variable that might be concurrently modified by multiple
threads should be declared volatile. Variables declared to be volatile
will not be optimized by the compiler because their value can change at
any time.
Q:26 What are the different types of errors in PHP?
A:26 Three are three types of errors:1. Notices: These are trivial,
non-critical errors that PHP encounters while executing a script – for
example, accessing a variable that has not yet been defined. By default,
such errors are not displayed to the user at all – although, as you will
see, you can change this default behavior.2. Warnings: These are more serious errors – for example, attempting
to include() a file which does not exist. By default, these errors are
displayed to the user, but they do not result in script termination.3. Fatal errors: These are critical errors – for example,
instantiating an object of a non-existent class, or calling a
non-existent function. These errors cause the immediate termination of
the script, and PHP’s default behavior is to display them to the user
when they take place.
Q:27 What is the functionality of the function strstr and stristr?
A:27 strstr:

Returns part of haystack
string from the first occurrence of
needle to the end of
haystack.If needle is not found,
returns FALSE.

If needle is not a
string, it is converted to an integer and applied as the
ordinal value of a character.

This function is case-sensitive. For
case-insensitive searches, use
stristr().

Q:28 What are the differences between PHP 3 and PHP 4 and PHP 5?
A:28 Please read the release notes at
http://www.php.net.
Q:29 How can we convert asp pages to PHP pages?
A:29 there are lots of tools available for asp to PHP conversion. you can
search Google for that. the best one is available athttp://asp2php.naken.cc./
Q:30 What is the functionality of the function htmlentities?
A:30 Convert all applicable characters to HTML entities
This function is identical to htmlspecialchars() in all ways, except
with htmlentities(), all characters which have HTML character entity
equivalents are translated into these entities.
Q:31 How can we get second of the current time using date function?
A:31 $second = date(”s”);
Q:32 How can we convert the time zones using PHP?
A:32 By using date_default_timezone_get and
date_default_timezone_set function on PHP 5.1.0


// Discover what 8am in Tokyo relates to on the East Coast of the US

// Set the default timezone to Tokyo time:
date_default_timezone_set('Asia/Tokyo');

// Now generate the timestamp for that particular timezone, on Jan 1st, 2000
$stamp = mktime(8, 0, 0, 1, 1, 2000);

// Now set the timezone back to US/Eastern
date_default_timezone_set('US/Eastern');

// Output the date in a standard format (RFC1123), this will print:
// Fri, 31 Dec 1999 18:00:00 EST
echo '

‘, date(DATE_RFC1123, $stamp) ,’

';?>
Q:33 What is meant by urlencode and urldocode?
A:33 URLencode returns a string in which all non-alphanumeric characters
except -_. have been replaced with a percent (%)
sign followed by two hex digits and spaces encoded as plus (+)
signs. It is encoded the same way that the posted data from a WWW form
is encoded, that is the same way as in
application/x-www-form-urlencoded media type.

urldecode decodes any %##
encoding in the given string.

Q:34 What is the difference between the functions unlink and unset?
A:34 unlink() deletes the given file from the file system.
unset() makes a variable undefined.
Q:35 How can we register the variables into a session?
A:35 $_SESSION[’name’] = “Mizan”;
Q:36 How can we get the properties (size, type, width, height) of an
image using PHP image functions?
A:36 To know the Image type use exif_imagetype () function
To know the Image size use getimagesize () function
To know the image width use imagesx () function
To know the image height use imagesy() function t
Q:37 How can we get the browser properties using PHP?
A:37 By using
$_SERVER['HTTP_USER_AGENT']
variable.
Q:38 What is the maximum size of a file that can be uploaded using PHP
and how can we change this?
A:38 By default the maximum size is 2MB. and we can change the following
setup at php.iniupload_max_filesize = 2M
Q:39 How can we increase the execution time of a PHP script?
A:39 by changing the following setup at php.inimax_execution_time = 30
; Maximum execution time of each script, in seconds
Q:40 How can we take a backup of a MySQL table and how can we restore
it. ?
A:40 To backup: BACKUP TABLE tbl_name[,tbl_name…] TO
‘/path/to/backup/directory’
RESTORE TABLE tbl_name[,tbl_name…] FROM ‘/path/to/backup/directory’mysqldump: Dumping Table Structure and DataUtility to dump a database or a collection of database for backup or
for transferring the data to another SQL server (not necessarily a MySQL
server). The dump will contain SQL statements to create the table and/or
populate the table.
-t, –no-create-info
Don’t write table creation information (the CREATE TABLE statement).
-d, –no-data
Don’t write any row information for the table. This is very useful if
you just want to get a dump of the structure for a table!
Q:41 How can we optimize or increase the speed of a MySQL select
query?
A:41
  • first of all instead of using select * from table1, use select
    column1, column2, column3.. from table1
  • Look for the opportunity to introduce index in the table you are
    querying.
  • use limit keyword if you are looking for any specific number of
    rows from the result set.
Q:42 How many ways can we get the value of current session id?
A:42 session_id() returns the session id for the current session.
Q:43 How can we destroy the session, how can we unset the variable of
a session?
A:43 session_unregister — Unregister a global variable from the current
session
session_unset — Free all session variables
Q:44 How can we destroy the cookie?
A:44 Set the cookie in past.
Q:45 How many ways we can pass the variable through the navigation
between the pages?
A:45
  • GET/QueryString
  • POST
Q:46 What is the difference between ereg_replace() and eregi_replace()?
A:46 eregi_replace() function is identical to ereg_replace() except that
this ignores case distinction when matching alphabetic
characters.eregi_replace() function is identical to ereg_replace()
except that this ignores case distinction when matching alphabetic
characters.
Q:47 What are the different functions in sorting an array?
A:47 Sort(), arsort(),
asort(), ksort(),
natsort(), natcasesort(),
rsort(), usort(),
array_multisort(), and
uksort().
Q:48 How can we know the count/number of elements of an array?
A:48 2 ways
a) sizeof($urarray) This function is an alias of count()
b) count($urarray)
Q:49 What is the PHP predefined variable that tells the What types of
images that PHP supports?
A:49 Though i am not sure if this is wrong or not, With the exif
extension you are able to work with image meta data.
Q:50 How can I know that a variable is a number or not using a
JavaScript?
A:50 bool is_numeric ( mixed var)
Returns TRUE if var is a number or a numeric string, FALSE otherwise.or use isNaN(mixed var)The isNaN() function is used to check if a value is not a number.
Q:51 List out some tools through which we can draw E-R diagrams for
mysql.
A:51 Case Studio
Smart Draw
Q:52 How can I retrieve values from one database server and store them
in other database server using PHP?
A:52 we can always fetch from one database and rewrite to another. here
is a nice solution of it.$db1 = mysql_connect(”host”,”user”,”pwd”)
mysql_select_db(”db1″, $db1);
$res1 = mysql_query(”query”,$db1);$db2 = mysql_connect(”host”,”user”,”pwd”)
mysql_select_db(”db2″, $db2);
$res2 = mysql_query(”query”,$db2);At this point you can only fetch records from you previous ResultSet,
i.e $res1 – But you cannot execute new query in $db1, even if you
supply the link as because the link was overwritten by the new db.so at this point the following script will fail
$res3 = mysql_query(”query”,$db1); //this will failSo how to solve that?

take a look below.
$db1 = mysql_connect(”host”,”user”,”pwd”)
mysql_select_db(”db1″, $db1);
$res1 = mysql_query(”query”,$db1);

$db2 = mysql_connect(”host”,”user”,”pwd”, true)
mysql_select_db(”db2″, $db2);
$res2 = mysql_query(”query”,$db2);

So mysql_connect has another optional boolean parameter which
indicates whether a link will be created or not. as we connect to the
$db2 with this optional parameter set to ‘true’, so both link will
remain live.

now the following query will execute successfully.
$res3 = mysql_query(”query”,$db1);

Thanks goes to Hasan and Hasin for this solution.

Q:53 List out the predefined classes in PHP?
A:53 Directory
stdClass
__PHP_Incomplete_Class
exception
php_user_filter
Q:54 How can I make a script that can be bi-language (supports
English, German)?
A:54 You can maintain two separate language file for each of the
language. all the labels are putted in both language files as variables
and assign those variables in the PHP source. on runtime choose the
required language option.
Q:55 What are the difference between abstract class and interface?
A:55 Abstract class: abstract classes are the class where one or more
methods are abstract but not necessarily all method has to be abstract.
Abstract methods are the methods, which are declare in its class but not
define. The definition of those methods must be in its extending class.Interface: Interfaces are one type of class where all the methods are
abstract. That means all the methods only declared but not defined. All
the methods must be define by its implemented class.
Q:56 How can we send mail using JavaScript?
A:56 JavaScript does not have any networking capabilities as it is
designed to work on client site. As a result we can not send mails using
JavaScript. But we can call the client side mail protocol mailto
via JavaScript to prompt for an email to send. this requires the client
to approve it.
Q:57 How can we repair a MySQL table?
A:57 The syntex for repairing a MySQL table is
REPAIR TABLENAME, [TABLENAME, ], [Quick],[Extended]
This command will repair the table specified if the quick is given the
MySQL will do a repair of only the index tree if the extended is given
it will create index row by row
Q:58 What are the advantages of stored procedures, triggers, indexes?
A:58 A stored procedure is a set of SQL commands that can be compiled and
stored in the server. Once this has been done, clients don’t need to
keep re-issuing the entire query but can refer to the stored procedure.
This provides better overall performance because the query has to be
parsed only once, and less information needs to be sent between the
server and the client. You can also raise the conceptual level by having
libraries of functions in the server. However, stored procedures of
course do increase the load on the database server system, as more of
the work is done on the server side and less on the client (application)
side.Triggers will also be implemented. A trigger is effectively a type of
stored procedure, one that is invoked when a particular event occurs.
For example, you can install a stored procedure that is triggered each
time a record is deleted from a transaction table and that stored
procedure automatically deletes the corresponding customer from a
customer table when all his transactions are deleted.Indexes are used to find rows with specific column values quickly.
Without an index, MySQL must begin with the first row and then read
through the entire table to find the relevant rows. The larger the
table, the more this costs. If the table has an index for the columns in
question, MySQL can quickly determine the position to seek to in the
middle of the data file without having to look at all the data. If a
table has 1,000 rows, this is at least 100 times faster than reading
sequentially. If you need to access most of the rows, it is faster to
read sequentially, because this minimizes disk seeks.
Q:59 What is the maximum length of a table name, database name, and
fieldname in MySQL?
A:59 The following table describes the maximum length for each type of
identifier.

Identifier Maximum Length
(bytes)
Database 64
Table 64
Column 64
Index 64
Alias 255

There are some restrictions on the characters that may appear in
identifiers:

Q:60 How many values can the SET function of MySQL take?
A:60 MySQL set can take zero or more values but at the maximum it can
take 64 values
Q:61 What are the other commands to know the structure of table using
MySQL commands except explain command?
A:61 describe Table-Name;
Q:62 How many tables will create when we create table, what are they?
A:62 The ‘.frm’ file stores the table definition.
The data file has a ‘.MYD’ (MYData) extension.
The index file has a ‘.MYI’ (MYIndex) extension,
Q:63 What is the purpose of the following files having extensions 1) .frm
2) .myd 3) .myi? What do these files contain?
A:63 In MySql, the default table type is MyISAM.
Each MyISAM table is stored on disk in three files. The files have names
that begin with the table name and have an extension to indicate the
file type.
The ‘.fr

m’ file stores the table definition.
The data file has a ‘.MYD’ (MYData) extension.
The index file has a ‘.MYI’ (MYIndex) extension,

Q:64 What is maximum size of a database in MySQL?
A:64 If the operating system or filesystem places a limit on the number
of files in a directory, MySQL is bound by that constraint.The efficiency of the operating system in handling large numbers of
files in a directory can place a practical limit on the number of tables
in a database. If the time required to open a file in the directory
increases significantly as the number of files increases, database
performance can be adversely affected.
The amount of available disk space limits the number of tables.
MySQL 3.22 had a 4GB (4 gigabyte) limit on table size. With the MyISAM
storage engine in MySQL 3.23, the maximum table size was increased to
65536 terabytes (2567 – 1 bytes). With this larger allowed table size,
the maximum effective table size for MySQL databases is usually
determined by operating system constraints on file sizes, not by MySQL
internal limits.The InnoDB storage engine maintains InnoDB tables within a tablespace
that can be created from several files. This allows a table to exceed
the maximum individual file size. The tablespace can include raw disk
partitions, which allows extremely large tables. The maximum tablespace
size is 64TB.
The following table lists some examples of operating system file-size
limits. This is only a rough guide and is not intended to be definitive.
For the most up-to-date information, be sure to check the documentation
specific to your operating system.
Operating System File-size LimitLinux 2.2-Intel 32-bit 2GB (LFS: 4GB)
Linux 2.4+ (using ext3 filesystem) 4TB
Solaris 9/10 16TB
NetWare w/NSS filesystem 8TB
Win32 w/ FAT/FAT32 2GB/4GB
Win32 w/ NTFS 2TB (possibly larger)
MacOS X w/ HFS+ 2TB
Q:65 Give the syntax of Grant and Revoke commands?
A:65 The generic syntax for grant is as following
> GRANT [rights] on [database/s] TO [username@hostname] IDENTIFIED BY
[password]
now rights can be
a) All privileges
b) combination of create, drop, select, insert, update and delete etc.We can grant rights on all databse by using *.* or some specific
database by database.* or a specific table by database.table_name
username@hotsname can be either username@localhost, username@hostname
and username@%
where hostname is any valid hostname and % represents any name, the *.*
any condition
password is simply the password of userThe generic syntax for revoke is as following
> REVOKE [rights] on [database/s] FROM [username@hostname]
now rights can be as explained above
a) All privileges
b) combination of create, drop, select, insert, update and delete etc.
username@hotsname can be either username@localhost, username@hostname
and username@%
where hostname is any valid hostname and % represents any name, the *.*
any condition
Q:66 Explain Normalization concept?
A:66 The normalization process involves getting our data to conform to
three progressive normal forms, and a higher level of normalization
cannot be achieved until the previous levels have been achieved (there
are actually five normal forms, but the last two are mainly academic and
will not be discussed).First Normal FormThe First Normal Form (or 1NF) involves removal of redundant data
from horizontal rows. We want to ensure that there is no duplication of
data in a given row, and that every column stores the least amount of
information possible (making the field atomic).Second Normal FormWhere the First Normal Form deals with redundancy of data across a
horizontal row, Second Normal Form (or 2NF) deals with redundancy of
data in vertical columns. As stated earlier, the normal forms are
progressive, so to achieve Second Normal Form, your tables must already
be in First Normal Form.Third Normal Form

I have a confession to make; I do not often use Third Normal Form. In
Third Normal Form we are looking for data in our tables that is not
fully dependant on the primary key, but dependant on another value in
the table

Q:67 How can we find the number of rows in a table using MySQL?
A:67 Use this for mysql
>SELECT COUNT(*) FROM table_name;
Q:68 How can we find the number of rows in a result set using PHP?
A:68 $result = mysql_query($sql, $db_link);
$num_rows = mysql_num_rows($result);
echo “$num_rows rows found”;
Q:69 How many ways we can we find the current date using MySQL?
A:69 SELECT CURDATE();
CURRENT_DATE() = CURDATE()
for time use
SELECT CURTIME();
CURRENT_TIME() = CURTIME()
Q:70 What are the advantages and disadvantages of Cascading Style
Sheets?
A:70 External Style SheetsAdvantagesCan control styles for multiple documents at once. Classes can be
created for use on multiple HTML element types in many documents.
Selector and grouping methods can be used to apply styles under complex
contextsDisadvantagesAn extra download is required to import style information for each
document The rendering of the document may be delayed until the external
style sheet is loaded Becomes slightly unwieldy for small quantities of
style definitionsEmbedded Style Sheets

Advantages

Classes can be created for use on multiple tag types in the document.
Selector and grouping methods can be used to apply styles under complex
contexts. No additional downloads necessary to receive style information

Disadvantages

This method can not control styles for multiple documents at once

Inline Styles

Advantages

Useful for small quantities of style definitions. Can override other
style specification methods at the local level so only exceptions need
to be listed in conjunction with other style methods

Disadvantages

Does not distance style information from content (a main goal of
SGML/HTML). Can not control styles for multiple documents at once.
Author can not create or control classes of elements to control multiple
element types within the document. Selector grouping methods can not be
used to create complex element addressing scenarios

Q:71 What type of inheritance that PHP supports?
A:71 In PHP an extended class is always dependent on a single base class,
that is, multiple inheritance is not supported. Classes are extended
using the keyword ‘extends’.
Q:72 What is the difference between Primary Key and
Unique key?
A:72 Primary Key: A column in a table whose values uniquely identify the
rows in the table. A primary key value cannot be NULL.

Unique Key: Unique Keys are used to uniquely identify each row in the
table. There can be one and only one row for each unique key value. So
NULL can be a unique key.There can be only one primary key for a table but there can be more
than one unique for a table.


Q:73
The structure of table view buyers is as follows:

Field

Type

Null

Key

Default

Extra

user_pri_id int(15) PRI null auto_increment
userid varchar(10) YES null

the value of user_pri_id the last row 999 then What will happen in
the following conditions?

Condition1: Delete all the rows and insert another row then.
What is the starting value for this auto incremented field user_pri_id ,
Condition2: Delete the last row(having the field value 999) and
insert another row then. What is the value for this auto incremented
field user_pri_id

A:73 In both cases let the value for auto increment field be n then next
row will have value n+1 i.e. 1000
Q:74 What are the advantages/disadvantages of MySQL and PHP?
A:74 Both of them are open source software (so free of cost), support
cross platform. php is faster then ASP and JSP.
Q:75 What is the difference between GROUP BY and ORDER BY in Sql?
A:75 ORDER BY [col1],[col2],…,[coln]; Tels DBMS according to what columns
it should sort the result. If two rows will hawe the same value in col1
it will try to sort them according to col2 and so on.GROUP BY
[col1],[col2],…,[coln]; Tels DBMS to group results with same value of
column col1. You can use COUNT(col1), SUM(col1), AVG(col1) with it, if
you want to count all items in group, sum all values or view average
Q:76 What is the difference between char and varchar data types?
A:76 Set char to occupy n bytes and it will take n bytes even if u r
storing a value of n-m bytes
Set varchar to occupy n bytes and it will take only the required space
and will not use the n bytes
eg. name char(15) will waste 10 bytes if we store ‘mizan’, if each char
takes a byte
eg. name varchar(15) will just use 5 bytes if we store ‘mizan’, if each
char takes a byte. rest 10 bytes will be free.
Q:77 What is the functionality of md5 function in PHP?
A:77 Calculate the md5 hash of a string. The hash is a 32-character
hexadecimal number. I use it to generate keys which I use to identify
users etc. If I add random no techniques to it the md5 generated now
will be totally different for the same string I am using.
Q:78 How can I load data from a text file into a table?
A:78 you can use LOAD DATA INFILE file_name; syntax to load data
from a text file. but you have to make sure thata) data is delimited
b) columns and data matched correctly
Q:79 How can we know the number of days between two given dates using
MySQL?
A:79 SELECT DATEDIFF(’2007-03-07′,’2005-01-01′);
Q:80 How can we know the number of days between two given dates using
PHP?
A:80 $date1 = date(’Y-m-d’);
$date2 = ‘2006-08-15′;
$days = (strtotime($date1) – strtotime($date2)) / (60 * 60 * 24);

 

 

  1. What does a special set of tags do in PHP? – The output is displayed directly to the browser.
  2. What’s the difference between include and require? – It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
  3. I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem? – PHP Interpreter treats numbers beginning with 0 as octal. Look at thesimilar PHP interview questions for more numeric problems.
  4. Would I use print “$a dollars” or “{$a} dollars” to print out the amount of dollars in this example? – In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like “{$a},000,000 mln dollars”, then you definitely need to use the braces.
  5. How do you define a constant? – Via define() directive, like define (“MYCONSTANT”, 100);
  6. How do you pass a variable by value? – Just like in C++, put an ampersand in front of it, like $a = &$b
  7. Will comparison of string “10” and integer 11 work in PHP? – Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.
  8. When are you supposed to use endif to end the conditional statement? – When the original if was followed by : and then the code block without braces.
  9. Explain the ternary conditional operator in PHP? – Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.
  10. How do I find out the number of parameters passed into function?– func_num_args() function returns the number of parameters passed in.
  11. If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b? – 100, it’s a reference to existing variable.
  12. What’s the difference between accessing a class method via -> and via ::? – :: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization.
  13. Are objects passed by value or by reference? – Everything is passed by value.
  14. How do you call a constructor for a parent class? – parent::constructor($value)
  15. What’s the special meaning of __sleep and __wakeup? – __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
  16. Why doesn’t the following code print the newline properly? $str = ‘Hello, there.\nHow are you?\nThanks for visiting TechInterviews’;
    print $str;
    ?>
    Because inside the single quotes the \n character is not interpreted as newline, just as a sequence of two characters – \ and n.
  17. Would you initialize your strings with single quotes or double quotes? – Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable substitution.
  18. How come the code works, but doesn’t for two-dimensional array of mine? – Any time you have an array with more than one dimension, complex parsing syntax is required. print “Contents: {$arr[1][2]}” would’ve worked.
  19. What is the difference between characters \023 and \x23? – The first one is octal 23, the second is hex 23.
  20. With a heredoc syntax, do I get variable substitution inside the heredoc contents? – Yes.
  21. I want to combine two variables together:
22.   $var1 = 'Welcome to ';
23.   $var2 = 'TechInterviews.com';

What will work faster? Code sample 1:

$var 3 = $var1.$var2;

Or code sample 2:

$var3 = "$var1$var2";

Both examples would provide the same result – $var3 equal to “Welcome to TechInterviews.com”. However, Code Sample 1 will work significantly faster. Try it out with large sets of data (or via concatenating small sets a million times or so), and you will see that concatenation works significantly faster than variable substitution.

  1. For printing out strings, there are echoprint and printf. Explain the differences. – echo is the most primitive of them, and just outputs the contents following the construct to the screen. print is also a construct (so parentheses are optional when calling it), but it returns TRUE on successful output and FALSE if it was unable to print out the string. However, you can pass multiple parameters to echo, like:

and it will output the string “Welcome to TechInterviews!” print does not take multiple parameters. It is also generally argued that echo is faster, but usually the speed advantage is negligible, and might not be there for future versions of PHP. printf is a function, not a construct, and allows such advantages as formatted output, but it’s the slowest way to print out data out of echo, print and printf.

  1. I am writing an application in PHP that outputs a printable version of driving directions. It contains some long sentences, and I am a neat freak, and would like to make sure that no line exceeds 50 characters. How do I accomplish that with PHP? – On large strings that need to be formatted according to some length specifications, use wordwrap() or chunk_split().
  2. What’s the output of the ucwords function in this example?
27.     $formatted = ucwords("TECHINTERVIEWS IS COLLECTION OF INTERVIEW QUESTIONS");
   print $formatted;

What will be printed is TECHINTERVIEWS IS COLLECTION OF INTERVIEW QUESTIONS.
ucwords() makes every first letter of every word capital, but it does not lower-case anything else. To avoid this, and get a properly formatted string, it’s worth using strtolower() first.

  1. What’s the difference between htmlentities() and htmlspecialchars()? – htmlspecialchars only takes care of <, >, single quote ‘, double quote ” and ampersand. htmlentities translates all occurrences of character sequences that have different meaning in HTML.
  2. What’s the difference between md5(), crc32() and sha1() crypto on PHP? – The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a 160 bit value. This is important when avoiding collisions.
  3. So if md5() generates the most secure hash, why would you ever use the less secure crc32() and sha1()? – Crypto usage in PHP is simple, but that doesn’t mean it’s free. First off, depending on the data that you’re encrypting, you might have reasons to store a 32-bit value in the database instead of the 160-bit value to save on space. Second, the more secure the crypto is, the longer is the computation time to deliver the hash value. A high volume site might be significantly slowed down, if frequent md5() generation is required.
  4. How do you match the character ^ at the beginning of the string? – ^\^

INTERVIEW QUESTIONS PART 3

by on Monday, February 20th, 2012

PHP interview questions, Part 2
Web dev interview questions
1. How can we repair a MySQL table?
2. What are the advantages of stored procedures, triggers, indexes?
3. What is the maximum length of a table name, database name, and fieldname in MySQL?
4. How many values can the SET function of MySQL take?
5. What are the other commands to know the structure of table using MySQL commands except explain command?
6. How many tables will create when we create table, what are they?
7. What is the purpose of the following files having extensions 1) .frm 2) .myd 3) .myi? What do these files contain?
8. What is maximum size of a database in MySQL?
9. Give the syntax of Grant and Revoke commands?
10. Explain Normalization concept?
11. How can we find the number of rows in a table using MySQL?
12. How can we find the number of rows in a result set using PHP?
13. How many ways we can we find the current date using MySQL?
14. What are the advantages and disadvantages of Cascading Style Sheets?
15. What type of inheritance that PHP supports?
16. How can increase the performance of MySQL select query?
17. The structure of table view buyers is as follows:
18. +—————-+————-+——+—–+———+—————-+
19. | Field | Type | Null | Key | Default | Extra |
20. +—————-+————-+——+—–+———+—————-+
21. | user_pri_id | int(15) | | PRI | NULL | auto_increment |
22. | userid | varchar(10) | YES | | NULL | |
23. +—————-+————-+——+—–+———+—————-+
the value of user_pri_id the last row 2345 then What will happen in the following conditions?
Condition1: Delete all the rows and insert another row then. What is the starting value for this auto incremented field user_pri_id ,
Condition2: Delete the last row(having the field value 2345) and insert another row then. What is the value for this auto incremented field user_pri_id
24. What are the advantages/disadvantages of MySQL and PHP?
25. What is the difference between GROUP BY and ORDER BY in Sql?
26. What is the difference between char and varchar data types?
27. What is the functionality of md5 function in PHP?
28. How can I load data from a text file into a table?
29. How can we know the number of days between two given dates using MySQL?
30. How can we know the number of days between two given dates using PHP?
31. How can we change the name of a column of a table?
32. How can we change the name and data type of a column of a table?
33. What are the differences between drop a table and truncate a table?
34. When you want to show some part of a text displayed on an HTML page in red font color, what different possibilities are there to do this? What are the advantages/disadvantages of these methods?
35. When viewing an HTML page in a Browser, the Browser often keeps this page in its cache. What can be possible advantages/disadvantages of page caching? How can you prevent caching of a certain page (please give several alternate solutions)?
36. What are the different methods of passing data or information between two calls of a web page? What are the advantages/disadvantages of these methods?
37. An Apache web server is running on a Linux system. Suddenly, the web server delivers the pages very slow. How could you find out possible reasons for that (when using system commands, please specify their names)?
38. What are the different ways to login to a remote server? Explain the means, advantages and disadvantages?
39. Please give a regular expression (preferably Perl/PREG style), which can be used to identify the URL from within a HTML link tag. Example: The regular expression should match the tag and give the URL (”http://www.yoursite.com /”) as a return result. Tags should also be matched if they contain other attributes than the HREF attribute.
40. A select query over a large table runs very slow because of the growing number of entries in that table. What different measures could be taken to improve speed?
41. A company wants to store their invoices in a database. They already have their customers and articles in that database. Both customer and article are each identified by an unique integer value. Please create the SQL statements for creating the necessary table(s) for storing the invoices in a MySQL database. An invoice should hold information like invoice number, customer, date, article(s) and quantity etc.
42. For the database from the previous question, please give an SQL query which returns the invoice number of all invoices which contain the article with the number “1234″. The query should be able to run under a MySQL 4.0 database.
43. How would you backup and restore a big MySQL database? What are the advantages of the approach which you have taken over the others?
44. Create a PHP web script with the following attributes: on start, three HTML form elements are shown: an string input field, a checkbox field, a dropdown/pull down list with 5 elements and a submit button. On submission, the form should be redisplayed (while remaining all options/inputs as the user has selected/entered them). Additionally, the selections/inputs of the user should be displayed in text. Please solve this without the use of any external libraries.
45. What is MIME?
46. What is PEAR in PHP?
47. How can I use the COM components in PHP?
48. How can I load the DLLs dynamically?
49. How many ways we can give the output to a browser?
50. How can we know that a session is started or not?
51. What is the default session time in PHP and how can I change it?
52. What changes I have to done in PHP.ini file for file uploading?
53. What are the differences between MySQL_fetch_array(), MySQL_fetch_object(), MySQL_fetch_row()?
54. How can I set a cron and how can i execute it in Unix, Linux, and windows?
55. Steps for the payment gateway processing?
56. How many ways I can register the variables into session?
57. Explain different types of errors in PHP (i.e. arguments in errorreporting function)?
58. How many ways I can redirect a PHP page?
59. List out different arguments in PHP header function?
60. What type of headers have to add in the mail function in which file a attached?
61. What is the difference between
62. What are the differences between PHP3 and PHP4 versions?
63. What are the differences between include() and include_once() functions?
64. Describe the importance of DABA BASE ABSTRACTION LAYERS in PHP and database connection?
65. Explain MySQL optimization?
66. What is the difference between using copy() and move() function in PHP file uploading?
67. What is the difference between Reply-to and Return-path in the headers of a mail function?
68. Explain about Type Juggling in PHP?
69. How can I get the only name of the current executing file?
70. How can I embed a java programme in PHP file and what changes have to be done in PHP.ini file?
71. How can I find what type of images that the PHP version supports?
72. The table tbl_sites contains the following data:
73. —————————————————–
74. Userid sitename country
75. ——————————————————
76. 1 sureshbabu indian
77. 2 PHPprogrammer andhra
78. 3 PHP.net usa
79. 4 PHPtalk.com germany
80. 5 MySQL.com usa
81. 6 sureshbabu canada
82. 7 PHPbuddy.com pakistan
83. 8. PHPtalk.com austria
84. 9. PHPfreaks.com sourthafrica
85. 10. PHPsupport.net russia
86. 11. sureshbabu australia
87. 12. sureshbabu nepal
88. 13. PHPtalk.com italy
Write a select query that will displayed the duplicated site name and how many times it is duplicated? …
Make sure you read Part 1 of PHP interview questions.

41 Comments so far »
1. Shatabdi said,
1. How can we repair a MySQL table?
The syntex for repairing a mysql table is
REPAIR TABLENAME, [TABLENAME, ], [Quick],[Extended]
This command will repair the table specified
if the quick is given the mysql will do a repair of only the index tree if the extended is given it will create index row by row
2. Shatabdi said,
3. maximum lenghth of mnames of database, table, columns
database- 64
table -64
columns-64
alias-255
3. Shatabdi said,
4.How many values can the SET function of MySQL take?
Mysql set can take zero or more values but at the maximum it can take 64 values
4. Kumar said,
What are the other commands to know the structure of table using MySQL commands except explain command?
describe table_name;
5. Kumar said,
How can we find the number of rows in a table using MySQL?
How can we find the number of rows in a result set using PHP?
Use this for mysql
>SELECT COUNT(*) FROM table_name;
but if u r particular about no of rows with some special result
do this
>SELECT [colms],COUNT(*) FROM table_name [where u put conditions];
and for PHP it cant be more simple
$result = mysql_query($any_valid_sql, $database_link);
$num_rows = mysql_num_rows($result);
echo “$num_rows rows found”;
6. Kumar said,
How many ways we can we find the current date using MySQL?
SELECT CURDATE();
CURRENT_DATE() = CURDATE()
for time use
SELECT CURTIME();
CURRENT_TIME() = CURTIME()
7. Kumar said,
Give the syntax of Grant and Revoke commands?
The generic syntax for grant is as following
> GRANT [rights] on [database/s] TO [username@hostname] IDENTIFIED BY [password]
now rights can be
a) All privilages
b) combination of create, drop, select, insert, update and delete etc.
we can grant rights on all databse by usingh *.* or some specific database by database.* or a specific table by database.table_name
username@hotsname can be either username@localhost, username@hostname and username@%
where hostname is any valid hostname and % represents any name, the *.* any condition
password is simply the password of user
The generic syntax for revoke is as following
> REVOKE [rights] on [database/s] FROM [username@hostname]
now rights can be as explained above
a) All privilages
b) combination of create, drop, select, insert, update and delete etc.
username@hotsname can be either username@localhost, username@hostname and username@%
where hostname is any valid hostname and % represents any name, the *.* any condition
8. Kumar said,
The structure of table view buyers is as follows:
+—————-+————-+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+—————-+————-+——+—–+———+—————-+
| user_pri_id | int(15) | | PRI | NULL | auto_increment |
| userid | varchar(10) | YES | | NULL | |
+—————-+————-+——+—–+———+—————-+
the value of user_pri_id the last row 2345 then What will happen in the following conditions?
Condition1: Delete all the rows and insert another row then. What is the starting value for this auto incremented field user_pri_id ,
Condition2: Delete the last row(having the field value 2345) and insert another row then. What is the value for this auto incremented field user_pri_id
In botth cases let the value for auto increment field be n then next row will have value n+1 i.e. 2346
9. Kumar said,
What is the difference between char and varchar data types?
Set char to occupy n bytes and it will take n bytes even if u r storing avalue of n-m butes
Set varchar to occupy n bytes and it will take only the required space and will not use the n bytes
eg. name char(10) will waste 5 bytes if we store ‘kumar’, if each char takes a byte
eg. name varchar(10) will just use 5 bytes if we store ‘kumar’, if each char takes a byte. rest 5 bytes will be free.
10. Kumar said,
What is the functionality of md5 function in PHP?
string md5(string)
Calculate the md5 hash of a string. The hash is a 32-character hexadecimal number. I use it to generate keys which I use to identify users etc. If I add random no techniques to it the md5 generated now will be totally different for the same string I am using.
11. Kumar said,
How can I load data from a text file into a table?
The mysql provides a LOAD DATA INFILE syntax. U can load data from a file. Gr8 tool but u need to make sure that
a) data is delimited
b) u match the colms and data correctly
dont use w/out first learning the syntax
12. Kumar said,
How can we know the number of days between two given dates using MySQL?
Use DATEDIFF()
>SELECT DATEDIFF(NOW(),’1947-08-15′);
will give u the exact no of days India got independence from British.
13. Kumar said,
How can we know the number of days between two given dates using PHP?
Simple arithmetic.
$date1 = date(”Y-m-d”);
$date2 = “1947-08-15″;
$days = (strtotime() – strtotime()) / (60 * 60 * 24);
echo ” No of $days we got independence from Britts”;
14. Kumar said,
How can we change the name of a column of a table?
How can we change the name and data type of a column of a table?
this will change the name of colm
> ALTER TABLE table_name CHANGE old_colm_name new_colm_name
this will change the name of colm and also the datatype
> ALTER TABLE table_name CHANGE old_colm_name new_colm_name [data type]
15. Kumar said,
What are the differences between drop a table and truncate a table?
>DROP TABLE table_name
Will DELETE the table and DATA
>TRUNCATE TABLE table_name
Will DELETE the table DATA not the table definition
16. Jigar said,
The structure of table view buyers is as follows:
+—————-+————-+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+—————-+————-+——+—–+———+—————-+
| user_pri_id | int(15) | | PRI | NULL | auto_increment |
| userid | varchar(10) | YES | | NULL | |
+—————-+————-+——+—–+———+—————-+
the value of user_pri_id the last row 2345 then What will happen in the following conditions?
Condition1: Delete all the rows and insert another row then. What is the starting value for this auto incremented field user_pri_id ,
Condition2: Delete the last row(having the field value 2345) and insert another row then. What is the value for this auto incremented field user_pri_id
Mr. Kumar has given its answer but if you have used mysql as backend and if you fire a query “delete from tablename” then in mysql it will reset auto index. so for condition one it will start from value 1.
for condition 2 it will start from n+1
17. Jigar said,
What is PEAR in PHP
PEAR is short for “PHP Extension and Application Repository” and is pronounced just like the fruit. The purpose of PEAR is to provide:
A structured library of open-sourced code for PHP users
A system for code distribution and package maintenance
A standard style for code written in PHP
The PHP Foundation Classes (PFC),
The PHP Extension Community Library (PECL),
A web site, mailing lists and download mirrors to support the PHP/PEAR community
PEAR is a community-driven project with the PEAR Group as the governing body. The project has been founded by Stig S. Bakken in 1999 and quite a lot of people have joined the project since then.
http://pear.php.net/manual/en/introduction.php
18. Nasim Abbas said,
A .66
select count(id) id ,sitename from tbl_sites group by sitename having id>1;
19. Sergej said,
What is the difference between GROUP BY and ORDER BY in Sql?
ORDER BY [col1],[col2],…,[coln]; Tels DBMS according to what columns it should sort the result. If two rows will hawe the same value in col1 it will try to sort them according to col2 and so on.
GROUP BY [col1],[col2],…,[coln]; Tels DBMS to group results with same value of column col1. You can use COUNT(col1), SUM(col1), AVG(col1) with it, if you want to count all items in group, sum all values or view average
20. Sergej said,
39. What is MIME?
MIME is Multipurpose Internet Mail Extensions is an internet standard for the format of e-mail. Howewer browsers also uses MIME standart to transmit files. MIME has a header wich is added to a begining of the data. When browser sees such header it shows the data as it would be a file (for example image)
some mimes:
audio/x-ms-wmp
image/png
aplication/x-shockwave-flash
21. pupu said,
44.How can we know that a session is started or not?
a session starts by session_start()function.
this session_start() is always declared in header portion.it always declares first.then we write session_register().
22. pupu said,
47.What are the differences between MySQL_fetch_array(), MySQL_fetch_object(), MySQL_fetch_row()?
Ans:- MySQL_fetch_array()->Fetch a result row as an associative array,numeric array.
MySQL_fetch_object()->Fetch a result row as an object.
MySQL_fetch_row()->Fetch a result set as an array().
23. Kripa said,
If we login more than one browser window at the same time with same user and after that we close one window then is the session is exist to other window or not.And if yes then why? or if no then why?
24. YQwe said,
If we login more than one browser window at the same time with same user and after that we close one window then is the session is exist to other window or not.And if yes then why? or if no then why?
session depends on browser. if browser is closed then session is lost. the session data will be deleted after session time out. if connection is lost and u recreate connection, then also sesssion will continue in the browser.
25. Abdu Rahiman said,
What is the maximum storage capacity of Mysql data,
Is Mysql not reliable, Why?
26. m. sivakumar said,
What are the database files stored in system?
Ans: data’s are stored in name.Myd
table Structure are name.$frm
Index tables are name.myi
27. m. sivakumar said,
what is the difference between groupby and order by in mysql?
Ans: Group by which is used to sort a table interms of colums
order by which is used to index a table by colum value
28. Moses Dinakran said,
Question No 47.
The difference between mysql_fetch_row() and mysql_fetch_array() is that the first returns the results in a numeric array ($row[0], $row[1] etc), while the latter returns a the results an array containing both numeric and associative keys ($row[”name”], $row[”email”] etc). mysql_fetch_object() returns an object ($row->name, $row->email etc).
29. sivakumar said,
difference between php4 and php5?
php4 cannot support oops concepts and zend engine1 will be used
in php5 support oops concepts and zends engine2 will be used
error supporting will increased in php5
xml and sqllite will be incresed in php5
30. amrita said,
if i have to use more than one forms in more than one function in javascript and use it in a single html page,how should it be done
31. Ashish Mathur said,
A.How can increase the performance of MySQL select query?
We can use LIMIT to stop MySql for further search in table after we have received our required no. of records, also we can use LEFT JOIN or RIGHT JOIN instead of full join in cases we have related data in two or more tables.
32. ALAGARSAMY said,
what about ob_start and ob_flush?
Ans:
ob_start is used to start the output buffer
ob_flush is used to refresh or clear the output buffer
33. Senthil said,
What is difference between MySql 4.0 and Mysql 5.0
34. nilanjan banerjee said,
what the difference between
mysql_connect and mysql_pconnect?
35. alagarsamy said,
father of pms
savan
36. siddhant singh said,
ALL MYSQL QUERY WHICH USED IN PHP.
1. mysql_connect
2. mysql_pconnect
3. mysql_select_db
4. mysql_query
5. mysql_fetch_array
6. mysql_fetch_assocs
7. mysql_fetch_row
8. mysql_fetch_object
9. mysql_close
10. mysql_fetch_field
11. mysql_fetch_leanth
12. mysql_fetch_affected_rows
13. mysql_create_db
14. mysql_data_seek
15. mysql_db_name
16. mysql_db_query
17. mysql_drop_db
18. mysql_error
19. mysql_field_flags
20. mysql_field_len
21. mysql_field_table
22. mysql_field_type
23. mysql_field_seek
24. mysql_free_result
25. mysql_insert_id
26. mysql_first_dbs
27. mysql_list_field
28. mysql_ping
29. mysql_hum_field
30. mysql_read_escape
can anyone tell me is this all complet query. which is used in php.
37. Rakesh Chandel said,
mysql_pconnect() is used to make a persistence connection to a database means that we can not close a persistence connection using mysql_close() also if a connection is already opened mysql_pconnect will use that connection and will not create another connection.
38. PHP interview questions, Part 1 | TechInterviews.com | « Interview questions for tech companies said,
[…] done? Read the second set of interview questions on PHP, or leave comments […]
39. Manokaran said,
What is Normalization ?
The process of simplifying a complex table into a simple form.
40. Manokaran said,
How many can ways we redirect from php page?
i. We can redirect from php page using header() function
ex:

header(”location:PAGE_NAME | PAGE_PATH”);
41. Meganathan said,
Different types of error reporting in php ?
error_reporting() function and its constant values
—————————————————
E_ERROR
E_WARNING
E_PARSE
E_NOTICE
E_CORE_ERROR
E_CORE_WARNING
E_COMPILE_ERROR
E_COMPILE_WARNING
E_USER_ERROR
E_USER_WARNING
E_USER_NOTICE
E_ALL
E_STRICT
E_RECOVERABLE_ERROR