Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Importing .csv Converting Date Back To 0000-00-00


I have imported a .csv file back in to MySql all the data has imported correctly. I never realised what a time saver working with .csv can be, as I always used to do find & replaces through notepad.

The only problem I am having is that the dates have defaulted to 0000-00-00




View Complete Forum Thread with Replies

Related Forum Messages:
Pear DB Converting ' To &#039 - How To Convert Back?
I have tested my logic flow and determined that the conversion from what is given to the

$db->prepare() statement and what is stored in the database iteslf goes

from:

"I'm helpful"
to
"I'm helpful"

is converted by pear's DB. I am using $db->prepare() statement. When I do a print_r() of $db after the prepare(), it does display:

...., field2 = 'I'm helpful', field3=....

but what ends up in the database is:

"I'm helpful"

I'm using PHP 4.3 and have tried html_entity_decode() and others unsuccessfully.

View Replies !
Converting Spaces To Underscores And Back In The Query String
I have a page that uses a variable in the query string to determine the output of the page. The query string will have a lot of spaces in it that look ugly when encoded to '%20' so my question is:

If the spaces in the query string were replaced with underscores, how would I replace the underscores with spaces in the page?

View Replies !
Converting Database Date To Normal Date
I am looking for a way to convert a date that is stored in a MySQL database like this after useing the date() function in PHP:

2006-08-16 21:03:54

and convert it into a date this:

16 August 2006 @ 11:03:54pm

Does anyone have some insight as to how I would go about doing that?

View Replies !
Importing Txt File Into DB,and Importing An Extra Variable For Each Row....
I want to allow the user to select a CSV file to upload details into my Db, along with a seprate variable, which is a session variable called $vendorid, this is set when they login.

So far I have the following, how can I insert the $vendorid in each row, along with the data from the text file? The Db has 11 columns, but the text file has 10, I want to set the 11th column to $vendorID for each row in the text file. Code:

View Replies !
Preserving Trailing Zeros In *.*0000
I am doing some date time calculations in which I need to add some no to mins, and so on. the result I get when I add 9.00 + 3.30 is 12.3. how can I preserve that trailing zero.

View Replies !
Date Converting
I am retrieving a date from mysql (using the mysql date format YYYY-MM-DD format). Is there an easy way to convert a date in that format:
YYYY-MM-DD
to this format:
MM-DD-YYYY

View Replies !
Converting To Date
I collect some data from a user registration form in the format:

Day: 1-31 Month: 1-12 Year- 1990-2007

how i can convert this into proper date format so i can store it in my database :P?

View Replies !
Unusual Behaviour Of Strtotime() For '0000-00-00 00:00:00' Input
I noticed a strange thing while using strtotime() and date()
functions in combination to generate from MySQL into a readable format.

By default, the MySQL date field will be 0000-00-00 00:00:00 When I
pass this to strtotime() to generate the timestamp, and then pass it to
the date function, it generates 30-11-1999.

[snippet]
<?
print ( "<br> strtotime for &#55612;&#57200;-00-00 00:00:00' : " . strtotime (
&#55612;&#57200;-00-00 00:00:00' ) );
print ( "<br> date for the above : " . date ( "d-m-Y", strtotime (
&#55612;&#57200;-00-00 00:00:00' ) ) );
?>
[/snippet]

I am on PHP 5.0.2
Why this unusual behaviour? Or is it an expected behaviour?

View Replies !
Converting A Date To A Weekday
Would like to create a function that takes a date (for example: 20031009) as input and returns its weekday (thursday) as output.

View Replies !
Converting Date Formats?
I have some dates in a MySQL database that are in a 'Y-m-d' format.
Is there a way to have PHP read these dates and convert them to a
'd-M-Y' format?

View Replies !
Converting A Calender Date
I am converting a calender date..i got a example from PHP Manual. the code is PHP Code:

View Replies !
Converting Date To Minutes
I have $x="200504161035"
that is 10:35 on 16 April 2005.

My questuion: what is the *shortest* piece of code to convert that variable
to minutes? I have a feeling there is a PHP function that should be able to
do it but I cannot find it. The long way takes 5 lines of code.

View Replies !
Converting MySQL Date With PHP
is there a PHP function that will convert a MySQL formatted date like "2004-09-05" to "July 9, 2004"?

View Replies !
Converting A Variable To Date
I searched around for a bit and tried reading the documentation on the date function, but I think I'm missing something, and figured someone could probably answer this pretty quickly.

I'm coding a schedule creator for my school's television station. It's pretty basic (lots of forms and messy sql insertions). Code:

View Replies !
Date Converting To Mysql
I have to convert date to mysql supported form with?

View Replies !
Converting MySQL Date To PHP Day Of The Year
i was wondering if anyone knew if there was a way to convert a MySQL Date (yyyy-mm-dd) to a PHP day of the year

date(z);

as in like January the first would be day 1 (or 0 )

View Replies !
Converting A Date To Unix Timestamp
I have a form where people enter their birthday_day, birthday_month, and birthday_year

Is there a way to do the following;

convert_this_to_unix_timestamp($_POST['birthday_day'], $_POST['birthday_month'], $_POST['birthday_year']);

The point is that if i store it as a unix_timestamp, then i can do some math on it and return the users age instead of their birthday.

View Replies !
Problem With Converting A Date In MySQL
I am having a problem with converting a date in MySQL. MySQL stores it as 2004-06-30 and I want to display it as 30 Jun 2004. How can I convert the MySQL string into the output I like?

To further complicate this, I also would like to add 6 months to the outputted date! Is this easy or impossible?

View Replies !
Converting Dates To Mysql Date Field
Is there a way to convert a date in this format:

8-7-2002 to fit into a MySQL date field format 2002-08-07.

the 8-7-2002 is a field in which users pick a date from a pop-up calendar in javascript. When I enter that date into the database, i want to convert it to the MySQL date format.....is there a way to convert it?

View Replies !
Converting Time Stamp To 'normal' Date Function
I'm looking for a bit of code/formulae to convert unix time stamp info into a conventional date format. I have a file that generates invoices from data requested from an sql table - trouble is it brings in the date as a timestamp. I'm looking for something I can plug into the php invoice file rather than altering the database.

View Replies !
Regex Issue - Converting A Written Date To A Timestamp
I have a problem, somehow through one of my scripts, all the timestamps in my database were set to 0000-00-00 00:00:00. I can fix this because one of the fields contains the written date in this format "Wednesday, June 7, 2006", I think I need to make a regex expression that can read that and generate a new timestamp from it,

I'm just not sure where to start because I've barely used regex. Some of the dates are not in that format because it contains over two years worth of data, and I want to just delete the ones that are not in that format as well. I'd appreciate any help here, I'm kind of stumped. Once I match the expression I can generate the timestamp, but I don't know how to match it.

View Replies !
Date_FORMAT Need To Convert Back To MySQL Date Format
Below is a couple of snippets of code that I have for modifying the date format from MySQL and it works great.  The problem I am running into is later in the code I need to call the $AuctionDate variable to query the data field in another table.  This won't work because the format has been modified using date_FORMAT.  How do I convert it back to the MySQL date format so I can properly query the database. Code:

View Replies !
Converting A Date Format (dd/mm/yyyy) Into A Time() Format
I want to convert a date in the format (dd/mm/yyyy) into a time() style format so I can compare it against the current time and only use information where its date is ahead of the current time.

View Replies !
Importing PDF Or EPS
Does anyone know of a way to import an existing PDF or EPS for editing without the commercial PDI library?

View Replies !
Importing CSS
I have a PHP script that displays a small calendar/diary block. It is called by an include() statement within the code of the target page on which we want the calendar displayed.

Both the calendar script and the target pages use different CSS files (with unique rule classes). The target pages are based on a common template which loads the main CSS file. We want to avoid having special templates/pages to load the calendar script CSS.

Question 1: How can I load CSS definitions in the PHP script without having to modify the header section os the target page?

Secondly, the calendar is displayed in different styles on different pages by setting a variable before the include() call. Each of the four styles uses a different CSS file.

Question 2: How can I load different CSS layouts depending upon the value of a PHP variable?

View Replies !
Importing Data
I have this file cvs that's roughly 2.5 meg. Right now, it uses a function like this to import the data into the table. PHP Code:

View Replies !
Importing Pages
I've written a content management system that I'm now selling to my
customers. It's very nice when we have a blank canvas of a site, but a pain
in the arse when there is already a site in place.

What I'm in the process of *trying* to put together is a script that would
do the following:

A simple form where you put the address of the site with the static pages

The script then spiders through the site, takes everything between <body>
and </body> and chucks the rest away

It would then take out all class definitions and all embedded styles like
font tags etc but leaves tables, <p> <H?> etc

This would leave a very plain page of HTML that would be inserted into a
database. CSS would control the fonts etc. I'm aware that there would need
to be some tidying up if there was any javascript or anything and also some
basic formatting.

What I want to know is

1. Has it been done and, if so, where might I find something like this
2. Might it have any commercial value to other developers?

Regarding 2, I'm thinking how much time something like this might save me if
I have to convert anything more than a few pages of static HTML into
something that I can put in a database.



View Replies !
Importing SQL Files
is it possile to import data from a sql file which has been exported from another database without using something like phpmyadmin ?  Or must it be done using phpmyadmin.

Also is it possible to just export data without having to use phpmyadmin or similar?

View Replies !
CSV Importing To MySQL
Well I had the last script working perfectly. Except sometimes we rearrange the CSV "headers" so a field may be in one place on one file and another place on another file, yet they are the same thing. I've tired about 30 different scripts and none of them work at all. For example:

Csv file looks like:
work order,client name,start date,end date
7283728,"name,client",02/07/07,04/02/07

that is just the test file I've made up. I found out, the hard way, you cannot have spaces in your database fields. So what I am trying to do is take that first line, replace all spaces with an _. That away database fields can be like work_order and in the CSV file also. I tried using Code:

View Replies !
Importing Xml To Mysql
i am using this piece of code to import an xml file to mysql.

$feed[$key] = $info;

is causing the script to only return the last element of the xml file.

I would like to return all elements but cant find a way to do so,

<?php
    include 'library/config.php'
    include 'library/opendb.php'
$file = "my-xml.xml";

$feed = array();
$key = "";
$info = "";


function startElement($xml_parser,  $attrs ) {
  global $feed;  
   }

function endElement($xml_parser, $name) {
  global $feed,  $info;
   $key = $name;
  $feed[$key] = $info;
  $info = ""; }

function charData($xml_parser, $data ) {
  global $info;
  
  
  $info .= $data; }
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "charData" );
$fp = fopen($file, "r");
while ($data = fread($fp, 8192))
!xml_parse($xml_parser, $data, feof($fp));
xml_parser_free($xml_parser);

$sql= "INSERT INTO section ( ";
$j=0;
$i=count($feed);

foreach( $feed as $assoc_index => $value )
  {
  $j++;
  $sql.= strtolower($assoc_index);
  if($i>$j) $sql.= " , ";
  if($i<=$j) {$sql.= " ) VALUES ('";}
  }
$h=0;
foreach( $feed as $assoc_index => $value )
  {
  $h++;
  $sql.= utf8_decode(trim(addslashes($value)));
  if($i-1>$h) $sql.= "', '";
  if($i<=$h) $sql.= "','');";
  }
  $query=trim($sql);
  echo $value;
if (mysql_query($sql)){
echo "success in table creation.";
} else {
echo "no table created.";
}
echo mysql_error();
  echo $sql;
?>

View Replies !
Importing Files Into PHP
I am trying to import files that have been exported to CSC or CSV, has anyone ever heard of this and could someone please tell me if there any tutorials on how to do this?

View Replies !
Importing MS Access
Is there a way to import an MS Access database .mdb file into MySQL running locally on a Mac?

View Replies !
Importing Databases
I just purchased a dedicated server and am moving my discussion forums from a VPS to my new server, which happens to use cPanel. Here's my problem. I created an account called for my site with a user named, lets just say "fred".

When I log into cPanel and use the MySql feature to create a database, it puts "fred" in front of the DB name. For example, sat I create a DB called "chat", well, what it acually creates is a DB called fred_chat. Then, when I try to import my original DB (chat), I get an error that the import script is creating a DB called "chat" and the access is denied for user fred@localhost.

View Replies !
Importing An Image Into Gd
I know that it is possible to use an image as a background for a file.

$im = ImageCreateFromPNG ($color.'-button.png');

But is it possible to import an image and place it on top of another as I already have the background I want.

View Replies !
Importing RSS Feeds
I am in the first stages of working on a RSS Feed site. Basically, it's going to aggregate hundreds of RSS feeds into channels of similarly related blogs. I think that the easiest thing would be to set up a cron to read all of the RSS feeds and import any new articles into the database.

I have code already to create my own RSS feeds from there on.What I want to know, and I've googled for this a bit but can't seem to find any answers, is there a way, or would I have to write a function, to parse the RSS feeds and then import them into the MySQL database?

View Replies !
Importing CSV File Into DB
I need to import a CSV file of events into my db. Could anyone point me in the right direction and tell me the best way to do it?

View Replies !
Importing Inventory
I'm developing a site which will periodically update inventory via a
large batch file. I'm wondering if anyone has ideas, caveats, etc on
how to update the inventory. At the moment, I'm simply uploading the
batch file via a web interface and in that same PHP page executing sql
to populate the database with the data from the batch file. Is this
the best way?

Should I write a shell script to do it? Should it be
done via the web or should someone have to log into the box to do it?
In all, it takes about 30 seconds to do the import, if that makes any
difference.

View Replies !
Importing A Txt File
I import a text file that has variables within it in the format of:

var1=test&var2=test...etc.

View Replies !
Importing Csv File
I'm importing some data from diferents tables in csv files but I have problems to import date values here is the code i'm using:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$fname="xlsdate.csv"; //reading csv file
$fp=fopen($fname,"r") or die("csv Error");
$line = fgets( $fp, 2024 );
$c=mysql_connect("localhost","root","");//conecting with db
if(!$c)
{
die("Not Conected"); }

It works perfect to import any kind of data but I don't know what should I do to import also date.

View Replies !
Importing From CSV Using LOAD DATA
what attributes should i use for a text coloum should it be binary?

View Replies !
Importing Data From Excel Into PHP
Is it possible to import data from excel file into php and than put it in
mysql database?

View Replies !
Import_request_variables Isn't Importing My Changes To My Globals
The server I'm running my PHP on has "magic_quotes" turned on, so all
the input I get (from GET, POST, and cookies) is escaped with
backslashes. I don't want this (I handle my own escaping, and I need to
be able to work with unescaped strings), but I'm not allowed to change
the setting on the server, so I need to figure out a way to "undo"
magic quotes.

This code itself works...

function stripslashes_array($v) {
return is_array($v) ? array_map('stripslashes_array', $v) :
stripslashes($v);
}
if (get_magic_quotes_gpc()) {
foreach (array('POST', 'GET', 'REQUEST', 'COOKIE') as $gpc)
$GLOBALS["_$gpc"] = array_map('stripslashes_array',
$GLOBALS["_$gpc"]);
}

But my problem is that I then want to use import_request_variables to
bring any form data into the global variable space, and that's not
reflecting the changes I just made to the globals... in other words, if
after that code I say:

$foo = "GLOBALS["_GET"]["test"];
import_request_variables("gp", "in_");
$bar = $in_test;

and I submit the page with "test" set to a'b'c, then $foo will be a'b'c
while $bar will be a'b'c.

How do I get the stripslashed values into my global variables without
having to stripslash each one individually?

View Replies !
Importing With PhpMyAdmin Error.
I've been testing import csv files with PHP. Well it's going ok, I guess, when you save with Excel everything works fine. The output .csv file is from another piece of software, and it appears to be completely fine. Look at this:

Line [1] from Excel saved CSV under "date" is this.
59:04.0

Line [1] from Software saved CSV under "date" is this.
2007-06-14 11:59:04.0

Excel takes out most of the date/time. When it is almost taken out it imports with PhpMyAdmin just fine. Well I need that date. For some reason when that date/time is complete MySQL kicks it back. Know the weird thing, I can go into PhpMyAdmin and insert just "2007-06-14 11:59:04.0" into the "date" column. So, this completely makes no sence why MySql is kicking it back. When I compare both csv files they are exactly alike, except the date; yet, there is no problem...anyone have any idea how to fix this? Or maybe a loop around it using PHP. I've got a class file that imports the Excel CSV just fine.

View Replies !
Using COM Objects Or Importing To Outlook
I've been asked to look at developing a web-based system for tracking forms.  In itself, it is fairly simple.  However, one item they want to look at is Outlook integration for tasks.  We use an internal exchange server and I have read about being able to use COM objects to write tasks for Outlook from PHP.

However, I'm having difficulty with this part. The script I do have is timing out and documentation on using COM objects is fairly sparse. Should I be looking at something other than PHP? Code:

View Replies !
Importing Sql File Into PHPMyAdmin
I get this error "#1064 - You have an error in your SQL syntax near 'collate latin1_general_ci NOT NULL,
PRIMARY KEY (`skills_id`)
) ENGINE=MyISAM' at line 3 "
when I import my file into PHPMyAdmin.
Can someone tell me why please?

View Replies !
Importing Umlaut Letters
I have a test file that contains some German words with umlauts in them, ä etc.

I import the file into PHP, using fgets().

This gives me one line at a time that I then decode and use. However the umlaut letters do not import correctly. They show as a square on the screen. Any ideas?

View Replies !
Importing A Large Database
I have a back of mysite in sql. And it appears that line 4114 is currupt or something.

Query: CREATE TABLE dstore ( uid varchar(255), name text, value text, enteredtime timestamp(14), id int(11) NOT NULL auto_increment, PRIMARY KEY (id), KEY nameidx (name) );

MySQL: BLOB column 'name' used in key specification without a key length

I'm using bigdump to import it. is there any other script that will do this where I can make it skip that line? I can't open in it and remove the line do to the database is far to large for that.

View Replies !
Importing CSV File Into MySQL
Im currently trying to import a CSV file into a MySQL database using myPHPAdmin 2.6.2, using the "Insert data from a text file into the table".

However when I do this, all the values in each of the cell has a large amount of spaces included. I have tried all the different configurations of importing the CSV data, but without success.

View Replies !
Importing Data Into Mysql
I have an excel sheet that I'm using to add product data to. And for the product descriptions, in a single cell of excel, I'm using bullets and return characters, so the data is somewhat formatted. From excel, I export as a tab delimited text file, and I then import this file into mysql using the following loadfile command: PHP Code:

load data infile './products.txt' into table products
    fields terminated by ' '
    optionally enclosed by '"'
    lines terminated by '
'

When the file is imported, the newline (returns) are ignored. Actually, the are read as spaces. Because at the end of one line, where it should have gone to the next line, there is now a space, and then the bullet of the next line, and everything is just "stuck" together. Any clues on where this mishap is happening? Is there something I need to add to the import to tell mysql that there are newline characters in the file, and that those should be kept? And if so, what would that newline character be?

View Replies !
Importing ITunes Library
Is there a way to get the data from my iTunes Library XML file which I will upload to my website to display on my website?

View Replies !
Importing A .txt File Into PhpMyAdmin
I'd like to import a .txt file or even a .csv file into a phpMyAdmin table. My table in phpma is set up as follows:

I have three fields set up in the table: candidate_id, first_name and last_name. The canditate_id is set up as follows:

Field: candidate_id, Type: INT, Attributes: unsigned, Null: not null, Extra: auto_increment, Primary key: checked

The first_name and last_name fields each have a VARCHAR type, a length/value of 40, and are set to not null. Code:

View Replies !
Importing Data Into A MySQL DB
Is there a way to import .dbx table to MySQL?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved