473,385 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problems with writing to flat file

133 100+
Hi,

I have a script which writes to a flat file and breaks it up like so:

[PHP]
<?php
$dblink="./data.db";
$moddb = file($dblink);
foreach($moddb as $data_line){
list($id, $catid, $image, $title, $desc) = explode('|', trim($data_line));
?>
[/PHP]

The problem is that when i add this to the database it puts the description over separate lines so it classes one entry as about 5 different ones.

How can i get around this, is there something i can do when adding the description to the database or is there a different way to display.

Cheers,
Adam
Apr 22 '08 #1
3 1200
ronverdonk
4,258 Expert 4TB
I assume that $desc is stored into 1 column of the table, but that it only splits in several lines in that column, yes? When so, you still have newline characters in the description data.
When not, please explain, because then I do not understand the question.

Ronald
Apr 22 '08 #2
adamjblakey
133 100+
I assume that $desc is stored into 1 column of the table, but that it only splits in several lines in that column, yes? When so, you still have newline characters in the description data.
When not, please explain, because then I do not understand the question.

Ronald
Yes you are correct.

The data is store like e.g.:

1|8|image.jpg|This is the Title|This is the description

The problem is that if i add a large description it splits it on to multiple lines so that it reads description as multiple entries when it is only one.
Apr 23 '08 #3
ronverdonk
4,258 Expert 4TB
Before you add the dscription to the file you must remove the newline characters ("\n") from it, because the FILE() command, upon reading the text again, will split its entries accoding to that newline character.

Ronald
Apr 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: CAFxX | last post by:
i'm writing a program that executes some calculations on a bitmap loaded in memory. these calculation ends up with pixel wth values far over 255, but i need them to be between 0 and 255 since i...
3
by: csx | last post by:
Hi all, Ive got a problem with recursion in Javascript. For this tree: http://www.pcm.uklinux.net/structure.jpg If you input node 3 (i.e. C) which is represented as 'values' in the array, it...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
12
by: Chris Springer | last post by:
I'd like to get some feedback on the issue of storing data out to disk and where to store it. I've never been in a production environment in programming so you'll have to bear with me... My...
5
by: Sheldon | last post by:
Hi everyone, I have a short program the writes the output data to an acsii file: import sys import os import string import gisdata from Numeric import *
3
by: Barry Flynn | last post by:
Hi I am working with a VB 2005 program which has been converted from VB6. It writes data out to a flat file, with code like the following line WriteLine(riFileNo, "Hist", lsAssetID,...
2
by: murthydb2 | last post by:
Hi My requirement is that i have to write a stored procedure in db2 and that will be executed in a batch file . Any system error or validation error that occurs inside the db2 sp during...
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
1
by: viv1tyagi | last post by:
Hi everyone ! ! ! I'm just a month old in the world of Python and trying to develop an application using Tkinter in which a new window pops out on a particular button press.The code for this new...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.