A small presentation that will help the beginners to understand the process of developing a Web application.
I did this presentation for the my Team @ Office to give them the idea of the whole process.
Archive for the ‘ PHP ’ Category
Here I tried to explain two advanced techniques in PHP.
1. Backtracing
2. Method Chaining
Apache
sudo apt-get install apache2
PHP
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
MySQL
To install the MySQL Server and Client packages.
sudo apt-get install mysql-server mysql-client
This will install the mysql server and client packages.
By default, recent Ubuntu/Debian systems install a MySQL Server from the 5-branch.
Set MySQL Root Password
By default, the root account of the MySQL Server is empty. To set the mysql root password do the following.
sudo mysqladmin -u root -h localhost password ‘mypassword’ #replace the ‘mypassword’ with your password.
Connect to MySQL from PHP / Ruby
Now you have Apache+PHP already installed, and want to connect to MySQL from PHP scritps.
For that you have to install one library, which is used to connect to mysql from PHP. Use this command to install the library.
sudo apt-get install php5-mysql
In case you are using Ruby, use the command
sudo apt-get install libmysql-ruby to connect to MySQL from Ruby.
Note : while restarting the apache if you get the following error
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
then open the /etc/apache2/apache2.conf file and add the following line
as the last line
ServerName “YourSitename or Servername”
save the file and restart the apache by giving the /etc/init.d/apache2 restart command, you will not get the error anymore.
To Install MySQL Query Browser, an GUI for MySQL
sudo apt-get install mysql-query-browser
After installation, to start MySQL Query Browser go to Applications > Programming > MySQL Query Browser.
Install PHP-GD Library
The GD Graphics Library is useful for dynamically creating, manipulating images. You will need to compile PHP with the GD library of image functions for this to work. However Ubuntu (and Debian) comes with package called php5-gd
To install GD for PHP use the following command.
sudo apt-get install php5-gd
I’ve collected the information from net which are required while installing and configuring Apache, PHP, MySQL and given here. Hope this will help for somebody who can get all information at one place.
So far we have seen how to trap the javascript errors in Part 1. Now we have
the data. We will see now, how to send data to the server using AJAX.
Send Data to Server
ajaxCtrl(
function(){
return true;
},"ajxerrorLogger.php",theData
);
The remote file is “ajxerrorLogger.php”.
I’ve used PHP for this.
Instead you can use ASP, JSP also.
This is used to receive the
data sent from the JavaScript error handling function. That’s it.
Our JavaScript errors are now sent to the server silently.
What Next? In the server side, we have to code the “ajxerrorLogger.php”
Receive Data and Write into a File
if($_POST && $_POST['file']!=''){
$filename = "./errlogs.txt";
$fh = fopen($filename,"a+");
//the content is in the form
//Date File LineNo Error Message
//(tab delimited)
$fcontent = date("d/m/Y h:i:s", mktime())."\t".
$_POST['file']."\t".$_POST['line']."\t".$_POST['err']."\r\n";
if (is_writable($filename)) {
if (fwrite($fh, $fcontent) === FALSE) {
}
fclose($fh);
}
}
$fh = fopen($filename,"a+");
Read the rest of this entry »
Introduction
Recently in one of my projects, I’m informed by my QA team
that, in some pages they’re experiencing crashes, or some pages not functioning
properly after sometime.
Our team looked for options where there can be a code
generating errors. And the feedback I got, from the QA team was not helpful to
reproduce the error. But there is no doubt to look for areas only in JavaScript
coding, and not other than JavaScript coding.
Normally while releasing a project, what I would do is, just
escape/bypass the JavaScript errors. That means, whenever there is a JavaScript
error, it will not be reported to the user and they are suppressed.
Background
Following is the function, we can normally use to suppress the JavaScript errors.
var isDebugging = true;
function ErrorSetting(msg, file_loc, line_no) {
var e_msg=msg;
var e_file=file_loc;
var e_line=line_no;
var error_d = "Error in file: " + file_loc +
"\nline number:" + line_no +
"\nMessage:" + msg;
if(isDebugging)
alert("Error Found !!!\n--------------\n"+error_d);
return true;
}
window.onerror = ErrorSetting;
window.onerror = ErrorSetting; this line will call the ‘ErrorSetting’
function, whenever there is a JavaScript error. And the function will return
true. So the user will not get JavaScript
error notifications and won’t be
annoyed. Read the rest of this entry »
// open the text file
$fd = fopen ("pilots.csv", "r");
// initialize a loop to go through each line of the file
while (!feof ($fd)) {
$buffer = fgetcsv($fd, 4096); // declare an array to hold all of the contents of each
//row, indexed
echo "n";
// this for loop to traverse thru the data cols
// when this is re-created with MySQL use the mysql_num_fileds() function to get
// this number
for ($i = 0; $i < 5; ++$i){
if ($buffer[$i] == ""){
$buffer[$i] = " ";
}
// print 's with each index
echo "$buffer[$i]n";
}
echo "n";
}
fclose ($fd);
?>
