473,765 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't insert spreadsheet edited in Linux with PHP script

I have no idea if this is a Linux issue or PHP. Looking for clues here.

I have a PHP script which I use to upload a CSV spreadsheet into a
mySQL database. (The script follows here in a sec.)
I was using WindowsXP and MS Excel to take these sheets, edit it if
needed, and save it in text based CSV. Then use the PHP script to
upload it and insert into the DB.

Now I've eschewed Windows and am using Fedora Core 3. I've tried doing
the same thing I always do, but with Open Office, and I've tried with
Gnumeric and KSpread, and I save it as CSV, but for some reason the PHP
script no longer properly uploads. It acts as if it's an empty file.

I don't think it's file folder or structure issue, because I'll edit it
in one of the three programs and then copy it to a WindowsXP machine
and upload it with the script and I get the same problem.

If I edit it and save it in CSV in MS Excel and then open it in
Notepad, I get proper lines with proper carriage returns in the right
places. If I edit it in a Linux program and then open it in an ASCII
editor it also looks just fine, but if I open it in Windows Notepad,
there carriage returns are in odd places and there's little squares
indicating a hidden or binary character here and there. Weird!

Any ideas what's going on here?
a) Is there anything I can do in one of the Linux programs (preferably
Open Office Calc) to save it properly in ASCII only CSV with proper
\r\n carriage returns? or
b) Anything I can do in the PHP to compensate for whatever the Linux
programs are doing to the CSV?

Thanks for any help!!
Here's the PHP:

$uploaddir = '/var/www/html/home/accounts/trackfiles/';
$upfilename = $_FILES['csvfile']['name'];
$uploadfile = $uploaddir . $upfilename;
move_uploaded_f ile($_FILES['csvfile']['tmp_name'], $uploadfile);
$change_perm = escapeshellcmd( "/bin/chmod a+rw -R
/var/www/html/home/accounts/trackfiles");
exec("$change_p erm 2>&1", $output);

// INSERT SPREADSHEET DATA INTO DATABASE
$sql = "LOAD DATA INFILE '".$uploadfile. "' INTO TABLE `".$tbl."` FIELDS
TERMINATED BY ','".
"OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\r\n'".
"(".$fields.")" ;
$result = @mysql_query($s ql, $dbconn) or die("Couldn't query DB: " .
mysql_error());

Jul 17 '05 #1
0 1557

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1795
by: xrongor | last post by:
hi. i need a simple, hopefully free html editor that besides the standard features has the following properties: allows frames. and will allow me to create a "directory" based on data from an excel
6
6768
by: Daniel | last post by:
Hi all, Can i open and edit the excel sheet on web page after downloading? After editing, i close the web page and the excel file auto upload to the server. Is it possible? I really struggling about the ability. If not, what advice can u provide? thank you in advance. ur help will be appreaciated.
0
3180
by: frankkirchner | last post by:
There has to be a way to get an image into the XSLT transormation process so that it shows up on a Formatted Excel Spreadsheet. When saving an Excel spreadsheet to XML format - you lose the image (a logo). When saving it to an HTM file - it saves the picture - but puts it into a local folder - for later retrieval. I am deriving the spreadsheet via VB.net code in asp.net environment and streaming the output via the respnse object (setting...
7
1510
by: Mark Knochen | last post by:
Hello, i have a php-script with a mysql_query ... $insert = mysql_query("INSERT INTO $table (textID,redaktion) VALUES ('$_POST','$row_startseiten')"); I get no mysql_error, if i copy the insert directly into phpmyadmin, the insert works. but with the php-script the insert doesn`t create a new row in the table .. but why?
3
15870
by: davnao | last post by:
I would like to open an existing workbook, select a work sheet and insert multiple rows at the top of the spreadsheet. Have the following code, but unsure of proper command & syntax for Insert row, and how to make it insert at row A1. With DataSheet .Sheets(2).Select .Rows.Insert .Cells(1, 1).Value = txtLine1 .Cells(2, 1).Value = txtLine2 .Cells(3, 1).Value =...
5
5086
by: Sport Girl | last post by:
Hi again my great online assistants, just would like to say that i'm testing the script under unix , and after researches on the internet, i have realised that to resolve 500 Internal Server Error, we should put the script in cgi-bin directory, use of ASCII transfer mode, chmod 755 scriptname.cgi, and then login to unix and type ./scriptname.cgi. I have connected to the database using mysql -u***** -p***** bugs and i could have access to the...
3
20830
by: JFKJr | last post by:
Hello everyone, I am trying to insert a picture in an excel spreadsheet cell using Access VBA. The following excel VBA code is working perfectly fine and I am able to insert picture in "A1" cell. But with the following Access VBA code, I am getting "Type Mismatch" error at line #13. Please kindly let me know how to solve this issue. Thanks a million in advance! Excel VBA: Sub InsertPic()
2
30173
by: franc sutherland | last post by:
Hello, I am using Access 2003. Is it possible to use string variables in the INSERT INTO statement? I am using the INSERT INTO statement to add a long list of contacts to a group by looping through the recordset (based on a linked spreadsheet, 'tbl_group_import') and using the INSERT INTO statement on each loop. I am using the rst.Fields.Item("FieldName") method to
5
4464
by: thatcollegeguy | last post by:
Below are my 3php and 2js files. I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know if I have the entirely wrong approach, but my code is below. Any or all help is appreciated! What currently happens is that the getdivision.php script works perfectly and gives me an entire table of correct data. The problem is that when I click...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9951
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.