Using Return Codes in PHP


I will show you how to execute a command on your server using system(). I will show you how to check if the command was successful using its return value.

To demonstrate this functionality we'll write a short script restarts your web server. Before restarting the server it will verify the configuration file is valid.

To execute a command we use the system() function. This function accepts as its first argument the command to execute, while the second argument is a variable you pass by reference that the return value is written to.
Note: You can also use functions such as exec() or passthru() if you need to access output from the program, but to keep things simple we'll ignore these functions.

The following listing shows how you to call system().
Listing 1 Accessing and outputting the return value from system() (listing-1.php)

<?php
system('/path/to/someCommand', $retval);
echo "Return value: " . $retval;
?>

If a command-line program has been written correctly, it will exit with a status code of 0 when the program executes correctly, or it will exit with a non-zero value when something does not work correctly.

The following listing shows a basic check of the return value. The specific error that has occurred will depend on the command being run.
Listing 2 Checking the return value and acting accordingly (listing-2.php)

<?php
system('/path/to/someCommand', $retval);

if ($retval == 0) {
echo "Executed correctly\n";
}
else {
echo "Some error occurred: " . $retval;
}
?>

To demonstrate this, we'll write a short script that calls makes use of the apachectl program. This is used to control an Apache installation (start / stop / restart the server). If you run this command with an argument of configtest it will tell you if the configuration is valid. If you run it with an argument of graceful it will restart the server (gracefully - that is, it will complete any active requests).

When you run apachectl configtest it will tell you if an error occurs, but additionally, it will exit with a code of 8 (you can see this documented inside the apachectl script).

Therefore, you can run this command and check if the configuration file is valid. If it is, we'll restart the server, if not, we won't. The following listing demonstrates this.
Listing 3 Restarting your Apache server if the configuration is valid (listing-3.php)

<?php
$ctl = '/usr/local/apache/bin/apachectl';

system($ctl . ' configtest', $retval);

if ($retval == 0) {
system($ctl . ' graceful');
}
else {
echo "Configuration error, unable to restart\n";
exit($retval);
}
?>

In this script we chained the return value. That is, when an error occurred we also exited with that return code. That way, if yet another script uses our PHP script they can also check the error code if required.

That's all there is to it! You could extend this script by checking the return value of the second command also, since this call can also fail.

Improving Web Performance from Page Components

On a web page images, flash, style sheets and scripts are some of the components that take time to load. For increasing the site load time, we might have to keep the site simple and reduce the number of web components on a page. The Http request/replies have to be kept at a minimum for optimum web performance.

The web page design needs to be simple by reducing the number of page components that take time to load. CSS sprites are one of the most preferred methods that reduce the number of image requests.

Response times are often impacted by user's proximity on web servers. When looked upon content for a solution, deploying content to server across multiple geographies will make the pages load faster. This can also be made unique to geography, looking upon the local market for the product or service, as this would definitely boost online businesses locally for their geographies.
Changing the architecture of the site can be a daunting task, synchronizing session state and replicating the database transactions across al the server locations. On an average, 80 to 90% of the time is spent on loading the components of the page. Its always a god idea to disperse static content rather then redesigning your site applications architecture. The front end engineers that care about web performance want a page to load progressively as soon as possible. This is very essential for the users who are looking out for a lot of content are on very low internet speeds.

Monitoring website applications in terms of performance should be focused in order to have optimum performing site. Web application monitoring solutions should be used to have comprehensive monitoring of web applications. Web performance is directly dependent on monitoring the website with different aspects in mind regarding all the components used on the website.

How to make 'her' fall in love with you

Searching for ways to make a woman fall in love with you can easily drive you up the wall. For a lot of men, just like you, women can be a little bit of a mystery. One moment you think that you are doing okay with a woman, and then the next moment, you are wondering if she is really into you at all. Is there a way that you can make sure that you can make her fall for you?
Here are some ways to make a woman fall in love that should get you going:

1. Be the kind of guy that she can feel secure with.
The only way to really make a woman feel this way is for her to see that YOU are a secure man. When a woman can sense that you are nervous or insecure around her, you are doing nothing to make HER feel security when she is with you. Don't assume that you have to act super macho to make a woman feel protected by you. You just have to leave her with the impression that she is with a confident alpha male that has no insecurities at all.

2. You have to be spontaneous with a woman.
To be honest, most guys ARE pretty boring. When they want to take a woman out on a date, they will do the tried and true dinner and a movie thing. You want to get used to being a little more spontaneous and think outside of the box once in a while when you are with a woman. You don't want her to be able to read your every move even before you make it. You want to be able to catch a woman by surprise and make her wonder what is going to happen next when she is with you.

3. You have to be able to go beyond the friend zone with a woman.
Being polite and being friendly is all well and good, but if you want to make a woman fall for you, if you want her to want you, then you have to go beyond that friend zone with her. If you hesitate to do this, or if you never really get beyond this stage with her, then you are only going to end up disappointed when you find out that she does not feel the same way about you that you do about her. Most men have been in this situation before, and you have to realize that it's a trap.

Resolving Error 8906 in MS SQL


In MS SQL Server database, a PFS (Page Free Space) page has one byte for each of the pages existing in the file interval it maps. This byte contains a bit that indicates that the associated page is a mixed page. An IAM page includes a mixed page array, which is an array of eight page IDs, to keep the mixed pages that have been allocated to the index. In some cases, when the database goes corrupted, the page containing 'mixed page' bit is not recognized correctly. Thus, you can detect such specific cases of database corruption and, take corrective measures for MS SQL Repair.

Most of the SQL database corruption problems can be analyzed and detected by running DBCC CHECKDB command. Let's consider the below error message, which typically appears when the discussed problem occurs. When you run DBCC CHECKDB command to check the integrity of database, following error might pop up:


Server: Msg 8906, Level 16, State 1, Line 0
Page P_ID in database ID DB_ID is allocated in the SGAM SGAM_P_ID and PFS PFS_P_ID, but was not allocated in any IAM. PFS flags 'PFS_FLAGS'.

Cause

Error 8906 is most likely to occur when a page with 'mixed page' bit set up in PFS byte has not been detected as an IAM page or in a mixed page array of an IAM page, which indicates database corruption.

Solution

If you encounter error 8906 after running DBCC CHECKDB on your SQL Server database, apply the below measures to solve it:

Run hardware diagnostics to isolate hardware-related problems. Corrupted hardware components are known to cause these issues if database corruption persists.
Restore the database from last good backup available.

If no clean backup is available, run DBCC CHECKDB without any repair clause to know the extent of damage and required SQL Repair clause. Again run DBCC CHECKDB command with the recommended repair clause. Make sure to backup your database before executing the repair command, in order to avoid post-crash results.
Use a third-party SQL Repair utility, in case DBCC CHECKDB doesn't work.


For best results, it is recommended to use Stellar Phoenix SQL Recovery software. Designed to run powerful and safe scanning algorithms, this SQL Repair utility can restore all database objects in a simple way. The application supports MS SQL Server 2008, 2005, and 2000.

WiMax for student



If you're currently enrolled in college, you're probably beginning to realize just how much technology is going to play a factor in your learning experience. While it used to be that the most high-tech piece of equipment you had to send a child off to school with might be a typewriter, these days it's not even enough to simply have a desktop or laptop computer--you must have the kind with the right amount of memory, the right capacity for handling a workload, and even particular software. And for befuddled parents, it's not the demands of one's children--it's the requirements of the particular departments of study.

Whether you're attending Central Texas College in Killeen or Greensboro College in Greensboro, technology has never been so important when it comes to getting a good education. But how can you possibly stay connected if you don't have a powerful wireless internet connection outside of the common spaces on campus? There are a couple of different ways to try and solve that sort of problem. You could split the cost of getting broadband with roommates and then invest in a router so that you also have wireless internet at home, but that would only result in a signal that ends up lagging because everyone is online at once. Or you could resolve to always study on campus, but that can quickly lead to trouble and frustration, as sometimes there are loud groups in the library, and the stress of getting to off-campus housing late at night is enough to be a deterrent to many students, especially young women.

So what's the best way to stay connected to everything from the latest discussion you're participating in via Blackboard to your friends back at home? A solid and reliable connection to the internet, for sure. But Wi-Fi signals are often limited or unreliable, and there's no way that you can tote a broadband connection around with you. So what's a smart college student to do?

Turn towards the future of technology, of course. Because so many college students are not weirded out by the prospect of getting online and updating their Facebook via their smartphone or even checking out a website on someone's iPad, the notion of using a lot of equipment in nontraditional ways seems like the norm. So something like WiMax, which is wireless signal for your web surfing that relies on towers like a cell phone company rather than using the typical old paradigm of getting online, makes a lot more sense. In fact, if you really look at things, it makes a lot more sense than dealing with the unreliable nature of using the on-campus network, where there are so many different students all connected that it is a wonder that the entire thing doesn't crash on a regular basis.

But there's something more about WiMax. If you're living in a dorm and don't want your roommate eavesdropping when you have sensitive conversations about being homesick, you can tote your laptop elsewhere and still manage to Skype without interruption. And if you are trying to find deals on textbooks, it's a lot more pleasant to scour the internet from the privacy of your own room rather than in the one spot in the common area where you can actually pick up the wireless signal. In short, it just makes considerably more sense if you want to be a part of a bright future to get on board with the technology that's going to get everyone there, sooner rather than later.

How to Optimize Your Dell Inspiron 1525 Battery


After used for a time, we can obviously feel that our computer getting more and more slow. The start time extend from 30 seconds to 1 minutes or more. When we use the computer to play game or wacthing video, the computer suddenly freeze. Then we should restart the laptop. Let me introduce some simple maintenance once or twice a month can make a difference in performance on all of his team.
  • Spyware, adware and viruses must be detected and cleaned frequently to maximize the efficiency of your computer.
  • Your Dell inspiron 1545 battery hard drive and personal files will be stored and managed properly to ensure that they are not damaged in the course.
  • Valuable information must be supported by a separate storage source such as a CD or DVD.
Use the following steps to clean the PC and then examine the steps in the Protect your PC against the most common problems to defend the security.

Step 1 - to undo harmful changes to the Windows System Restore

Undo harmful changes to the Dell Inspiron 1501 Battery using Windows System Restore. This tool is located in front of your computer to a date that unwanted software is installed or started receiving the annoying pop-ups

Step 2 - Malicious Software Removal

Install anti-virus software and keep virus definition files current is the best way to preserve the health of your computer. Test your Dell Inspiron 1525 Battery computer's exposure to online security threats and learn more about the HP recommends anti-virus solution on the connection from Symantec Security.

Step 3 - Manage efficiently drive

Manage your hard disk more efficiently using Microsoft Windows built-in system tools. Disk Cleanup deletes temporary files and other data that make the computer slower. Defragmentation program takes all the scattered data and grouped them together in the front of the unit and helps your hard drive work faster and more data.
In the end we advice you backup your computer and reinstall your OS once a year.