The sports page records people's accomplishments, and the front page shows you the people's failures.
That is so true!
:):):)
The sports page records people's accomplishments, and the front page shows you the people's failures.
That is so true!
:):):)
I am testing it with the csv file now...
Well, It uploaded the csv file perfectly as well....hmmm...I wonder if it's because of the die statement....I will re-run the upload without the die statement...
I had commented off the print_r in the code...could that have affected the upload?
No, the upload went ahead perfectly....all the data was uploaded, and filled out in the table...so I am seeing the 300000+ records in the table...
I don't understand why it didn't work before though.....
Ok, So I checked my file, and it really contains only 348269 records...therefore it works...
1. I uploaded a txt file and not a csv file
2. I replaced
$qry = mysql_query($query,$conn);
with
$qry = mysql_query($query,$conn) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno($conn) . ") " . mysql_error($conn));
those were the only 2 things that I did differently today...
Excellent article. I frequently refer to it in my posts:
Here's the complete article
And the part I always refer to : click
It saves me alot of writing :)
Thanks niek_e ;)
I was doing some light reading...and the following I'd like to share....
There is a community, a shared culture, of expert programmers and networking wizards that traces its history back through decades to the first time-sharing minicomputers and the earliest ARPAnet experiments. The members of this culture originated the term ‘hacker’. Hackers built the Internet. Hackers made the Unix operating system what it is today. Hackers run Usenet. Hackers make the World Wide Web work.
The hacker mind-set is not confined to this software-hacker culture. There are people who apply the hacker attitude to other things, like electronics or music — actually, you can find it at the highest levels of any science or art. Software hackers recognize these kindred spirits elsewhere and may call them ‘hackers’ too — and some claim that the hacker nature is really independent of the particular medium the hacker works in.
There is another group of people who loudly call themselves hackers, but aren't. These are people (mainly adolescent males) who get a kick out of breaking into computers and phreaking the phone system. Real hackers call these people ‘crackers’ and want nothing to do with them. Real hackers mostly think crackers are lazy, irresponsible, and not very bright, and object that being able to break security doesn't make you a hacker any more than being able to hotwire cars makes you an automotive engineer. Unfortunately, many journalists and writers have been fooled into using the word ‘hacker’ to describe crackers; this irritates …
Got this from some light reading.....
Do not blame yourself for past errors. You are no longer the same person who made them and you cannot blame a person who does not exist.
Hey....Good Morning,
It is 8:16am here when I started to upload the file of 30.4MB...now the time is 8:20 am and it seems to be uploading still...
R0bb0b, I did put in the die statement at the end of my query, and this was my test, but it seems to working....I also did not upload the csv file, but the txt file...so I will keep you all posted...8:24am and still uploading...I hope it works now...
It is 8:33am and it worked (only problem is that instead of loading the total 348270 records, it loaded 348269 records then gave the error message...)...I have attached it...
it's a csv file with approximately 40 MB of data..
playing jokes sounds like fun....but then there's a limit...
F6 and F9 are much less keys to ttype...lol...
:):):)
No need to apologize, just ponder ;)
:):):)
This is just the Question of the Day thread all over again.
I humbly apologize, but when I started this thread, I did not see the Question of the Day thread...I will mark this thread as solved. Thanks for pointing that out.
Is there a setting in the MySQL Administrator to set the file upload size?
Here is my table:
Field Type Null Key Default Extra
account varchar(20) NO
service varchar(20) YES
date varchar(20) NO
time varchar(20) NO
timebandtype varchar(20) YES
destination varchar(20) NO
callednumber varchar(20) NO
mins varchar(20) NO
airtimecharge varchar(20) NO
tollcharge varchar(20) YES
amt varchar(20) NO
privatenumber varchar(20) NO
Is there a setting in the MySQL Administrator to set the file upload size?
Hi Everyone,
Is it possible for a table in MySQL to be updated on a regular basis from an Oracle database?
I like to see this one ---->
Thant's really cool...
:) :) :)
well, i don't drink alcohol
I don't fancy it either...
Right now I am eating some frosted flakes, and drinking a hot cup of coffee....and the rain is falling too...
How do "please keep off the grass" signs get there?
Wouldn't it be nice if whenever we messed up our life, we could simply
press Ctrl Alt Delete and start all over?
I got this via email....I don't know who made it up...
A computer was something on TV
From a science fiction show of note
A window was something you hated to clean
And ram was the cousin of a goat.
Meg was the name of my girlfriend
And gig was a job for the nights
Now they all mean different things
And that really mega bytes.
An application was for employment
A program was a TV show
A cursor used profanity
A keyboard was a piano.
Memory was something that you lost with age
A CD was a bank account
And if you had a 3-inch floppy
You hoped nobody found out.
Compress was something you did to the garbage
Not something you did to a file
And if you unzipped anything in public
You'd be in jail for a while.
Log on was adding wood to the fire
Hard drive was a long trip on the road
A mouse pad was where a mouse lived
And a backup happened to your commode.
Cut you did with a pocketknife
Paste you did with glue
A web was a spider's home
And a virus was the flu.
I'll stick to my pad and paper
And the memory in my head
No one's been killed in a computer crash
But …
One day my housework-challenged husband decided to wash his
Sweat-shirt. Seconds after he stepped into the laundry room, he
shouted to me, "What setting do I use on the washing machine?
"It depends," I replied. "What does it say on your shirt?"
He yelled back, " University of Oklahoma "
And they say blondes are dumb...
To want to be what one can be is purpose in life.
Cynthia Ozick, O Magazine, September 2002
:-O huh?!?:confused: :icon_confused: :icon_sad:
I don't know why it doesn't work here...:@ let me scrutinize the code once more...I'll let you know what's going on...
But it works with the small csv I have....
I just deleted most of the records from full csv file, and renamed it to 'smallcsv'...so it's the same datatypes throughout...*sigh*...did u try with a rather large file? about 300000 records...
:confused: beats me...:icon_confused:
let me repost the code...perhaps there's we missed...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Upload Bill</title>
<style type="text/css">
<!--
.style28 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 18px;
font-weight: bold;
color: #006600;
}
.style29 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
}
-->
</style>
<style type="text/css">
<!--
.style27 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
}
body {
background-color: #CCFFCC;
}
.style30 {
color: yellow;
font-size: 14px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.style31 {
color: #CCFFCC;
font-weight: bold;
}
.style32 {color: yellow; font-weight: bold; }
.style33 {font-size: 14px; font-family: Verdana, Arial, Helvetica, sans-serif;}
-->
</style>
</head>
<body onload="goforit()">
<table width="200" border="0" align="center">
<tr>
<th colspan="6" scope="col"><img src="images/apBanner2.png" width="962" height="225" /></th>
</tr>
<tr>
<td width="155"><img src="images/btnT.png" width="150" height="33" /></td>
<td width="155"><img src="images/btnA.png" width="150" height="33" /></td>
<td width="155"><img src="images/btnI.png" width="150" height="33" /></td>
<td width="155"><img src="images/btnS.png" width="150" height="33" /></td>
<td width="327" colspan="2">
<div align="center">
<script>
/*
Live Date Script-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions, 100's more DHTML scripts, and Terms Of Use,
visit http://www.dynamicdrive.com
*/
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
function getthedate()
{
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12)
{
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font …
WellI got bad news, good news, and bad news...
Bad News: It wasn't uploading the full file, so I just tried 100000 records...:(
Good News: It uploaded the file with 100000 records but...:)
Bad News: In the database, the data wasn't stored, but the rows were created...:(
Besides....it would be cheaper...you wouldn't have to constantly buy the compressed air...
:):):)
Althought the dust doesn't seem to bother me, it does actually bother my sister and brother...so when I have to clean my computer I use the vaccuum cleaner....I just make sure and not to bother the components...
okie dokie....
well, I would put it upload now, and when I return to work on Friday, I would check it...(tomorrow is a Public Holiday in my country...so I won't be doing any work on it...that should give it enough time to fully run)
nav33n, thanks so much for your help thus far...:):):)
nav33n,
I have tried uploading files with different amount of records...I started of with 10 records, 1000 records, 5000 records...and they were uploaded (seperately), I tried 10000 records, 100000 records, and up...and they obviously didn't work...
I noticed that while uploading the file with the 5000 records, the pc sorta froze...does this consume alot of resources for such a small amount of data to be uploaded?
this is the print_r
Array ( [0] => 127000769106 [1] => 630-3228 [2] => 1/11/2007 [3] => 7:58:46 [4] => DY [5] => TRINIDAD [6] => 18683555181 [7] => 4:00:00 [8] => 0 [9] => 3.2 [10] => 3.2 [11] => P0 )
Array ( [0] => 127000769106 [1] => 630-3228 [2] => 1/11/2007 [3] => 8:05:44 [4] => DY [5] => TRINIDAD [6] => 18687631516 [7] => 8:00:00 [8] => 0 [9] => 6.4 [10] => 6.4 [11] => P0 )
.
.
.
while (($data = fgetcsv($handle, 100000, ',', '"')) !== FALSE)
{
print_r($data);
echo("<br />");
$value1 = $data[0];
$value2 = $data[1];
$value3 = $data[2];
$value4 = $data[3];
$value5 = $data[4];
$value6 = $data[5];
$value7 = $data[6];
$value8 = $data[7];
$value9 = $data[8];
$value10 = $data[9];
$value11 = $data[10];
$value12 = $data[11];
echo("<br />");
$query = "INSERT INTO testtsttbills (account,service,date,time,timebandtype,destination,callednumber,mins,airtimecharge,tollcharge,amt,privatenumber) VALUES ('$value1','$value2','$value3','$value4','$value5','$value6','$value7','$value8','$value9','$value10','$value11','$value12')";
$qry = mysql_query($query,$conn);
}
strange...it still doesn't work for the larger file...
Here's one that caught my eye 1 day...
It does not matter how slowly you go so long as you do not stop.
Confucius
There are those little round bread that the bakeries (where I am from) makes and they call it 'hops'...it could hold the sandwich meat properly...it is not as big as the bread used for burgers though...
well I increased the amount of time from 60 to 1800...that should give way for any file that may be more than 30MB...I also removed the semicolon...
to be clear....can I use
EITHER set_time_limit(0) in the script OR max_execution_time = 1800
or can I use
set_time_limit(0) in the script AND max_execution_time = 1800
:)
I put the
set_time_limit(0)
to the top of my script.
These are the settings I have in my php.ini file:
max_execution_time = 60
max_input_time = 60
memory_limit = 128Mpost_max_size = 80M
;upload_tmp_dir = "c:/uploads/tmp" (do I need to remove the semicolon to the beginning of this line in the .ini file?)
upload_max_filesize = 80M
I tried upload the smal file, and it works...I then tried the larger file, and in about 5-10 seconds the page is refreshed...and nothing is uploaded...
oho...ok...
I have 2 test files
1. 348270 records. 30.4MB
2. 10 records. 864bytes
When I test the smaller file, it works great...but when I tried the larger file, it doesn't even move on to say "The file was uploaded."
Code:
if(in_array($ext, $allowedext))
{
$filename = $_FILES['file']['tmp_name'];
//move_uploaded_file($filename,"upload/".$_FILES['file']['name']);
//$fh = fopen($_FILES['file']['tmp_name'], 'r');
$handle = fopen($filename, "r");
while (($data = fgetcsv($handle, 100000, ',', '"')) !== FALSE)
{
//echo ("data<br />");
//echo $data;
//echo ("<br />data_array<br />");
//$data_array = explode(",",$data);
//print_r ($data_array);
//echo ("<br />");
$value1 = $data[0];
$value2 = $data[1];
$value3 = $data[2];
$value4 = $data[3];
$value5 = $data[4];
$value6 = $data[5];
$value7 = $data[6];
$value8 = $data[7];
$value9 = $data[8];
$value10 = $data[9];
$value11 = $data[10];
$value12 = $data[11];
$query = "INSERT INTO testtsttbills VALUES ('$value1','$value2','$value3','$value4','$value5','$value6','$value7','$value8','$value9','$value10','$value11','$value12')";
$qry = mysql_query($query,$conn);
}
//$contents = fread($handle, filesize($filename));
fclose($handle);
//echo $contents;
echo "<div align='center'><font color='red'>The file was uploaded.</font></div>";
}
here is the code:
while (($data = fgetcsv($handle, 100000, ',', '"')) !== FALSE) {
echo ("data<br />");
echo $data;
echo ("<br />data_array<br />");
$data_array = explode(",",$data);
print_r ($data_array);
echo ("<br />");
$value1 = $data_array[0];
$value2 = $data_array[1];
$value3 = $data_array[2]; $value4 = $data_array[3];
$value5 = $data_array[4];
$value6 = $data_array[5];
$value7 = $data_array[6];
$value8 = $data_array[7];
$value9 = $data_array[8];
$value10 = $data_array[9];
$value11 = $data_array[10];
$value12 = $data_array[11];
$query = "INSERT INTO testtsttbills VALUES ('$value1','$value2','$value3','$value4','$value5','$value6','$value7','$value8','$value9','$value10','$value11','$value12')"; $qry = mysql_query($query,$conn); }
here is what it prints:
data
Array
data_arrayNotice: Array to string conversion in /var/www/html/billUploadTest.php on line 265
Array ( [0] => Array )Notice: Undefined offset: 1 in /var/www/html/billUploadTest.php on line 270
Notice: Undefined offset: 2 in /var/www/html/billUploadTest.php on line 271
Notice: Undefined offset: 3 in /var/www/html/billUploadTest.php on line 272
Notice: Undefined offset: 4 in /var/www/html/billUploadTest.php on line 273
Notice: Undefined offset: 5 in /var/www/html/billUploadTest.php on line 274
Notice: Undefined offset: 6 in /var/www/html/billUploadTest.php on line 275
Notice: Undefined offset: 7 in /var/www/html/billUploadTest.php on line 276
Notice: Undefined offset: 8 in /var/www/html/billUploadTest.php on line 277
Notice: Undefined offset: 9 in /var/www/html/billUploadTest.php on line 278
Notice: Undefined offset: 10 in /var/www/html/billUploadTest.php on line 279
Notice: Undefined offset: 11 in /var/www/html/billUploadTest.php on line 280
I took off move_uploaded_file and I also changed the delimiter from ; to ,
and I am getting the same error...
Hi,
Here is my code:
<?
include ("./connect.php");
global $conn;
ini_set("display_errors", "1");
error_reporting (E_ALL);
if(count($_FILES) > 0)
{
$ext = "";
$ext = substr(trim($_FILES["file"]["name"]), -4);
$allowedext = array(".txt", ".csv", ".sql");
if(in_array($ext, $allowedext))
{
$filename = $_FILES['file']['tmp_name'];
move_uploaded_file($filename,"upload/".$_FILES['file']['name']);
//$fh = fopen($_FILES['file']['tmp_name'], 'r');
$handle = fopen($filename, "r");
while (($data = fgetcsv($handle, 100000, ',', '"')) !== FALSE)
{
$data_array = explode(";",$data);
$value1 = $data_array[0];
$value2 = $data_array[1];
$value3 = $data_array[2];
$value4 = $data_array[3];
$value5 = $data_array[4];
$value6 = $data_array[5];
$value7 = $data_array[6];
$value8 = $data_array[7];
$value9 = $data_array[8];
$value10 = $data_array[9];
$value11 = $data_array[10];
$value12 = $data_array[11];
$query = "INSERT INTO testtsttbills (account,service,date,time,timebandtype,destination,callednumber,mins,airtimecharge,tollcharge,amt,privatenumber) VALUES ('$value1','$value2','$value3','$value4','$value5','$value6','$value7','$value8','$value9','$value10','$value11','$value12')";
$qry = mysql_query($query,$conn);
}
//$contents = fread($handle, filesize($filename));
fclose($handle);
//echo $contents;
echo "<div align='center'><font color='red'>The file was uploaded.</font></div>";
}
else
{
echo "<div align='center'><font color='red'>You are trying to upload an invalid file format. Please try again.</font></div>";
}
}
?>
Here is the result: (this displays for the exact number of rows of data in the file)
Warning: move_uploaded_file(upload/smallTestFile.csv) [function.move-uploaded-file]: failed to open stream: No such file or directory in /var/www/html/billUploadTest.php on line 255
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phprGU33K' to 'upload/smallTestFile.csv' in /var/www/html/billUploadTest.php on line 255
Notice: Array to string conversion in /var/www/html/billUploadTest.php on line 262
Array
Notice: Undefined offset: 1 in /var/www/html/billUploadTest.php on line 264Notice: Undefined offset: 2 in /var/www/html/billUploadTest.php on line 265
Notice: Undefined offset: 3 in /var/www/html/billUploadTest.php on line 266
Notice: Undefined offset: 4 in /var/www/html/billUploadTest.php on line 267
Notice: Undefined offset: 5 in /var/www/html/billUploadTest.php on line 268
Notice: Undefined …
Gravitation cannot be held responsible for people falling in love. How on earth can you explain in terms of chemistry and physics so important a biological phenomenon as first love? Put your hand on a stove for a minute and it seems like an hour. Sit with that special girl for an hour and it seems like a minute. That's relativity.
Albert Einstein
Having a cup of coffee...how heavenly...*sigh*
I dress right. <er, when I wear a suit>.
I usually buy my clothes at Ross or Costco.
I bought stuff at Ross too....
ok, and what about the values?
could it be done like pulling the data into an array or something?
I understand what you are saying....
yes i did run it in the query browser, and it ran well....with hardcoded data...
here it is:
insert into testtsttbills (account,service,date,time,timebandtype,destination,callednumber,mins,airtimecharge,tollcharge,amt,privatenumber) values ('127000769106','630-3228','1/11/2007','7:58:46','DY','TRINIDAD','18683555181','4:00:00','0','3.2','3.2','P0')
when the data was read
$handle = fopen($filename, "r");
the order that it was read is the order in which the data in sent
...('". implode("','", $data)."')
from the php manual...i got this for the return value of implode():
Returns a string containing a string representation of all the array elements in the same order, with the glue string between each element.
In a previous thread (when I was creating this script) someone gave me that chunk of code to try...and it worked....but only on small files...