WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 Resources
Web Development Content
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

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 : 6824
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  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
How to Insert a Date Format Into MySQL from PHP
Categories : PHP, Databases, MySQL, Date Time, Beginner Guides
Save and restore files into postgresql database (PHP SCRIPT) PHP CLASS
Categories : PHP, Databases, PostgreSQL, Filesystem
Fetching product details from the commission junction website using php
Categories : PHP, FTP, Filesystem, Compression
Query Timer
Categories : PHP, Databases, Date Time
mysql date/time converters
Categories : PHP, MySQL, Databases, Date Time
Finding the day of the week for a specific date.
Categories : PHP, Databases, MySQL, Date Time
Using PHP to Delete a directory with all sub directories and files using FTP
Categories : PHP, FTP, Directories, Filesystem
A wrapper function to format dates coming from a databases with the same syntax as PHP's date() function.
Categories : Date Time, Databases, PHP
Monthly and Daily Upcoming Events calendar.
Categories : Date Time, PostgreSQL, PHP, Calendar, Databases
Simple function to return the number of days in a time span between 2 given dates.
Categories : PHP, Date Time, MySQL, Databases
Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support
Categories : PHP, FTP, Filesystem, PHP Classes, Compression
Simple conversion functions to change MySQL dates to arrays, arrays to MySQL dates.
Categories : PHP, Arrays, Date Time, Databases, MySQL
Phorum, MySQL, Language, UK date format, MySQL UK Date format
Categories : PHP, Date Time, Strings, MySQL, Databases
Convert a File database into MySQL
Categories : PHP, Filesystem, Databases, MySQL, Beginner Guides