dennismonsewicz
Members-
Posts
1,136 -
Joined
-
Last visited
Everything posted by dennismonsewicz
-
reading the contents of a csv file
dennismonsewicz replied to dennismonsewicz's topic in PHP Coding Help
ok i have the code update and its reading the file contents updated code: $action = $_GET['action']; $session_id = $_GET['osCAdminID']; $targetPath = 'Upload/'; $randomNumber = rand(1000, 9999); switch($action) { case "upload": foreach($_FILES['file']['tmp_name'] as $key => $value) { if(move_uploaded_file($_FILES['file']['tmp_name'][$key], $targetPath . $randomNumber . '-' . $_FILES['file']['name'][$key])) { $aryFiles[] = $randomNumber . '-' . $_FILES['file']['name'][$key]; } else { $continue = 99; } if($continue == 99) { echo '<strong>There was a problem uploading your files</strong>'; } else { foreach($aryFiles as $key => $file) { $lnct = 0; $fileRead = fopen($targetPath . $file, 'r'); while(!feof($fileRead)) { $fileContent[$key][$lnct] = explode(',',fgets($fileRead)); foreach($fileContent[$key][$lnct] as $subkey => $column) { $quoFix = $column; if(substr($quoFix, 0, 1) == '"') $quoFix = substr($quoFix, 1, (strlen($quoFix)-1)); if(substr($quoFix, (strlen($quoFix)-1), 1) == '"') $quoFix = substr($quoFix, 0, (strlen($quoFix)-1)); if($quoFix) $fileContent[$key][$lnct][$subkey] = $quoFix; } $lnct++; } fclose($fileRead); } } } print_r ($fileContent); Now i want to compare the contents from array 1 and contents from array 2. The file contents are read line for line and placed into an array. $fileContent[0] is one array and $fileContent[1] is another array. I can't use array_diff() cause the column counts are different in each file... any ideas here? -
reading the contents of a csv file
dennismonsewicz replied to dennismonsewicz's topic in PHP Coding Help
yeah the code just creates an inifinite loop and causes my browser to crash... updated code: foreach($_FILES['file']['name'] as $n => $name) { if(!empty($name)) { $target_path = "Upload/" . $name; if(move_uploaded_file($_FILES['file']['tmp_name'][$n], $target_path)) { $i=0; $handle = @fopen($target_path, "r"); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle); $pieces = explode(",", $buffer); $x=0; while($pieces[$x]) { $your_array[$i].=$pieces[$x]; $x++; } print_r($your_array); $i++; } } } } } -
reading the contents of a csv file
dennismonsewicz replied to dennismonsewicz's topic in PHP Coding Help
ok so it created an infinite loop... updated code: foreach($_FILES['file']['name'] as $n => $name) { if(!empty($name)) { $target_path = "upload_path/" . $name; if(move_uploaded_file($_FILES['file']['tmp_name'][$n], $target_path)) { $i=0; $handle = @fopen($target_path, "r"); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle); $pieces = explode(",", $buffer); $x=0; while($pieces[$x]) { $your_array[$i].=$pieces[$x]; } print_r($your_array); $i++; } } } } } -
reading the contents of a csv file
dennismonsewicz replied to dennismonsewicz's topic in PHP Coding Help
here is what line of code from one of the files looks like 000-100-034,"FEED FRAME INSERT ",83,000-100-034.jpg,328 NEW STYLE,754,"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","" -
reading the contents of a csv file
dennismonsewicz replied to dennismonsewicz's topic in PHP Coding Help
i get this error message Notice: Undefined offset: 2 Then the word Array is printed all the way down the screen -
reading the contents of a csv file
dennismonsewicz replied to dennismonsewicz's topic in PHP Coding Help
this is the code i just updated and i am getting a blank screen: foreach($_FILES['file']['name'] as $n => $name) { if(!empty($name)) { $target_path = "upload_path/" . $name; if(move_uploaded_file($_FILES['file']['tmp_name'][$n], $target_path)) { $i=0; $handle = @fopen($name, "r"); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle); $pieces = explode(",", $buffer); $one = $pieces[0]; $two = $pieces[1]; $three = $pieces[2]; $your_array[$i]=$one.",".$two.",".$three; echo $your_array . "<br />"; $i++; } } } } } -
reading the contents of a csv file
dennismonsewicz replied to dennismonsewicz's topic in PHP Coding Help
thanks for the code... i will be testing it now... this is a good start at least. I am going to be needing to compare two csv files and where ever there is a match up between the two files it is to insert the contents in to a set of db tables. And the ones that could not match up there is supposed to be a error report generated showing the entries that could not be matched up -
how do i parse the data in a csv file to read every chunk of data? i want to place the contents of the csv file into an array with the delimiter being a comma
-
thanks sasa! Its been a really long week... getting laid off from your job is a week killer!
-
I have the following error from my code: Warning: Invalid argument supplied for foreach() in csv_upload.php on line 10 Here is my code: foreach($_FILES['file']['name'] as $n => $name) { if(!empty($name)) { $target_path = "path_to_upload_folder/" . $name; if(move_uploaded_file($_FILES['file']['tmp_name'][$n], $target_path)) { echo 'files loaded'; } } } form code: echo '<form action="csv_upload.php?action=upload&osCAdminID=' . $session_id . '" method="post">'; echo '<label for="file1">File 1</label> <input type="file" name="file[]" />'; echo '<br /><br />'; echo '<label for="file2">File 2</label> <input type="file" name="file[]" />'; echo '<br /><br />'; echo '<input type="submit" value="Submit Information" />'; echo '</form>';
-
I have this array: $myArr=array("<b>Id</b>","<b>Project</b>","<b>Project Id</b>","<b>PM</b>","<b>Designer</b>","<b>PM</b>","<b>Writer</b>","<b>PM</b>","<b>Designer</b>","<b>PM</b>","<b>Christine</b>","<b>PM</b>","<b>Designer</b>", "<b>PM</b>","<b>Julie</b>","<b>PM</b>","<b>Designer</b>","<b>PM</b>","<b>Proofreading</b>","<b>PM</b>","<b>Layne</b>","<b>PM</b>","<b>Programming</b>","<b>PM</b>","<b>Testing</b>"); How do i go about going through each item in the array and making it bold without having to place the <b></b> tags in the array?
-
try this http://us3.php.net/manual/en/function.mysql-get-server-info.php
-
Color Subject line in the mail function
dennismonsewicz replied to fohanlon's topic in PHP Coding Help
this cannot be done... as the color of the subject line is handled by the users choice of email client. -
you could create an info.php script like this <?php phpinfo(); ?> And then just run it in your browser
-
Change if((isset$_POST['apply']) to if(isset($_POST['apply']))
-
try echoing out $_POST['apply'] and see what you get
-
try this if (empty($fname)){ $error .='No first name<br>'; }
-
Copying a DB entry to another DB
dennismonsewicz replied to dennismonsewicz's topic in PHP Coding Help
can you give me an example? I am wanting to say something to the affect of copy this row into this DB WHERE id = (insert id # here) -
change $_POST[apply] to $_POST['apply']
-
Is there a way to copy an entire row into another DB specific to its row id?
-
[SOLVED] copying one file from one folder into another
dennismonsewicz replied to dennismonsewicz's topic in PHP Coding Help
thanks everyone! I am working on the archiving script now... i was just a little unsure on moving the files! Thanks for all of your help! -
I used to work in a MAC environment and used Dreamweaver and had no problems with it
-
I have a website that allows users to upload files. I am wanting to display those files and next to the individual files display a delete link/button and when the user clicks that link/button it will delete the file without having to reload the page. Can anyone point me in the right direction for a good tutorial on how to do this?
-
As I was typing that Discomatt beat me too it! So i Second his motion!