PHP Classes

reply To: Extracting data from a word file for insertion into my

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  reply To: Extracting data from a...  
Subject:reply To: Extracting data from a...
Summary:reply to: How do I Extract data from a word file for insertion i
Messages:3
Author:riccardo castagna
Date:2010-03-21 00:54:52
Update:2010-03-21 21:44:43
 

  1. reply To: Extracting data from a...   Reply   Report abuse  
Picture of riccardo castagna riccardo castagna - 2010-03-21 00:54:54
this is the class file name: class.word.php
<?php
class word{
var $dbHost = "localhost";
var $dbUser = "root";
var $dbPass = "";
var $dbName = "worddoc";

function insertion(){
$connect;
$db;
$create;
{
/*CONNECT TO MYSQL SERVER*/
$this->connect=mysql_connect($this->dbHost, $this->dbUser, $this->dbPass) or die ("Errore durante la connessione al server mysql");
/** CREATE A BATABASE ****/

$this->create=mysql_query("CREATE DATABASE IF NOT EXISTS ".$this->dbName." ;");
/*SELECT THE DATABASE*/
$this->dbnew=mysql_select_db($this->dbName, $this->connect) or die ("Errore durante la connessione al database $this->dbName");
echo "<br />database ".$this->dbName." created";
/*CRATE A TABLE FOR THE INSERTION */
$sql = "CREATE TABLE IF NOT EXISTS wordcont (
id int(2) NOT NULL auto_increment,
wordtext longtext NOT NULL,
PRIMARY KEY (id))
ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;";

$exesql = mysql_query($sql);




$my_file = 'file.doc';//path to the word file
$handle = fopen($my_file, 'r');
$data = fread($handle,filesize($my_file));

$insert = "INSERT INTO wordcont (wordtext) VALUES ('$data');";
$exeinsert = mysql_query($insert);

$select = "SELECT * FROM `wordcont`;";
$exeselect = mysql_query($select);
$row = mysql_fetch_array($exeselect);
echo $row['wordcont'];



}
}
}
?>
and this to execute the class
<?php
include_once('class.word.php');
$ref=new word;
$ref->insertion();
?>

There are 2 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.