WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : A PHP Script that shows how to use FTP to run a shell script, read two local files and update data in a database.
Categories : PHP, Filesystem, FTP, Date Time, Databases Click here to Update Your Picture
mahendra Rao
Date : Nov 13th 2007
Grade : 1 of 5 (graded 1 times)
Viewed : 1450
File : No file for this code example.
Images : No Images for this code example.
Search : More code by mahendra Rao
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

This script reads two type of files and updates a sales table. First it executes the shell script file. After that it reads the .out files and then i updates one of the table in a database.

<?php

$ftps
= array( host => "localhost",user => "ftp",psswd => "");

//Openning an ftp connection
$conn = ftp_connect( $ftps["host"] );

if( !
$conn ){
    echo
"FTP server connection error" . "<BR>";
    exit;
}
else{
   echo
"Connected to FTP Server" . "<BR>";

//Login to the FTP server.
@$result = ftp_login( $conn, $ftps["user"], $ftps["psswd"] );

if( !
$result){
    echo
"The page couldn't log in as : " . $ftps["user"] . "<BR>";
   
ftp_quit( $conn );
    exit;
}
echo
"You are user: " . $ftps["user"] . "<BR>";

//Getting the file's time from the FTP_Server.
$time = ftp_mdtm( $conn, "/alex/hola.txt" );
echo
date("D d-M-Y -- H:i:s", $time) . "<BR>";

//Executing a shell script.
//my_script is a shell script which only has an echo statement.

$res = ftp_exec($conn, "/src/shell_scripts/my_script");
echo
"Script Shell result: " . $res;


$readfile = file("var/www/html/rt.out");
for (
$k=0; $k<=count($readfile)-1; $k++) {
   
$fields = split("\t",$readfile[$k]);
   
   
$rt = "UPDATE sales set date ='$fields[0]', downloads='$fields[2]' where type = 'rt'";
}
$readfile1 = file("var/www/html/rbt.out");
for (
$k=0; $k<=count($readfile1)-1; $k++) {
   
$fields = split("\t",$readfile1[$k]);
   
$rbt = "UPDATE sales set date ='$fields[0]', downloads='$fields[2]' where type = 'rbt'";
}

ftp_quit( $conn );
}

?>






Checks Date-Input from HTML-Forms and converts to YYYY-MM-DD Format for MySQL Date-Fields
Categories : MySQL, Date Time, PHP, Databases
Save and restore files into postgresql database (PHP SCRIPT) PHP CLASS
Categories : PHP, Databases, PostgreSQL, Filesystem
Count how many weeks in the month have a specified day, such as Mon, Tue, etc. Var avail - number of days - first day name of the month, occurrences of Sun, occurrences of Mon, etc. Allows you to calculate number of working hours exclude Holidays.
Categories : Calendar, Date Time, PHP, Databases, MySQL
Phorum, MySQL, Language, UK date format, MySQL UK Date format
Categories : PHP, Date Time, Strings, MySQL, Databases
How to Insert a Date Format Into MySQL from PHP
Categories : PHP, Databases, MySQL, Date Time, Beginner Guides
PHP Transfer data from text file to Mysql Table
Categories : PHP, PHP Classes, Filesystem, Databases, MySQL
mysql date/time converters
Categories : PHP, MySQL, Databases, Date Time
Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support
Categories : PHP, FTP, Filesystem, PHP Classes, Compression
Monthly and Daily Upcoming Events calendar.
Categories : Date Time, PostgreSQL, PHP, Calendar, Databases
Simple pipe delimited file export program that downloads to a local machine
Categories : PHP, Filesystem, Databases, MySQL, HTTP
Convert a File database into MySQL
Categories : PHP, Filesystem, Databases, MySQL, Beginner Guides
Moving folder hierarchy b/w server
Categories : PHP, FTP, Filesystem
How to Convert a MySQL Timestamp to a USA Date & Time
Categories : PHP, MySQL, Databases, Date Time
Directory TreeView - File Manager & Explorer - FTP - Utility - PHP/HTML -
Categories : PHP, Directories, FTP, Filesystem, HTML and PHP
A wrapper function to format dates coming from a databases with the same syntax as PHP's date() function.
Categories : Date Time, Databases, PHP