473,804 Members | 3,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about DB & accessing fixed records from local C:\ .txt file

Is it possible to take the contents of a MySQL DB Table, and somehow
put the data into a syntax-correct data file format like a delimited
..txt file, and using PHP parse it as a local c:\ file assuming it was
sitting in C:\data.txt ..... so I want to read its contents in a
similar method as you would query a DB table .... can you do this the
same with a blob of data stored in a .TXT file?

If so, how to format .txt & php code -- I would very much like to
emulate this scenario against a c:\ stored .txt file:

<?
$sql_query = "SELECT * FROM localfile WHERE value = '$somevalue'";
$result = @mysql_query($s ql_query,$db);

// now put all the data into arrays
$a = 0;
while ($row = mysql_fetch_row ($result)) {

$somearray1[$a] = $row[0];
$somearray2[$a] = $row[1];

$a++;
}
?>

Can something like this be done? :)

Dec 11 '06 #1
2 1132
Rik
ap**********@gm ail.com wrote:
Is it possible to take the contents of a MySQL DB Table, and somehow
put the data into a syntax-correct data file format like a delimited
.txt file, and using PHP parse it as a local c:\ file assuming it was
sitting in C:\data.txt ..... so I want to read its contents in a
similar method as you would query a DB table .... can you do this the
same with a blob of data stored in a .TXT file?

If so, how to format .txt & php code -- I would very much like to
emulate this scenario against a c:\ stored .txt file:

<?
$sql_query = "SELECT * FROM localfile WHERE value = '$somevalue'";
$result = @mysql_query($s ql_query,$db);

// now put all the data into arrays
$a = 0;
while ($row = mysql_fetch_row ($result)) {

$somearray1[$a] = $row[0];
$somearray2[$a] = $row[1];

$a++;
}

Not really an answer to your question, but maybe an answer to your actual
problem/reason for wanting this:
SQLite uses only files, hardly any administration needed, check it out:
http://www.php.net/manual/en/ref.sqlite.php
http://sqlite.org/

Offcourse it's totally possible to dump a mysql database in sqlite, with
most of the major normal sql functionality intact.
--
Rik Wasmus
Dec 12 '06 #2
C.

ap**********@gm ail.com wrote:
Is it possible to take the contents of a MySQL DB Table, and somehow
put the data into a syntax-correct data file format like a delimited
.txt file,
Yes - take a look at mysqldump, but it might be simpler to roll your
own.
and using PHP parse it as a local c:\ file assuming it was
sitting in C:\data.txt ..... so I want to read its contents in a
similar method as you would query a DB table
Yes - IIRC there's an ODBC driver for CSV files (but the last time I
used it was about 10 years ago - maybe MS don't ship it any more).
>.... can you do this the
same with a blob of data stored in a .TXT file?
Yes - but you'll need to encode it first. A better solution would be to
write each blob to its own file and reference the file from the table.

Although it is *possible* to do all this, it doesn't make a lot of
sense - a better solution would be SQLite or DBM.

C.

Dec 12 '06 #3

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

Similar topics

8
2959
by: Frnak McKenney | last post by:
Back when computer dinosaurs roamed the earth and the precursors to today's Internet were tiny flocks of TDMs living symbiotically with the silicon giants, tracking access to data processing resources was much simpler: you logged in with a userID and password, and when you were done you ended your session by logging out (or occasionally by being disconnected). Connection time was easy to measure, and it made sense to both the customer...
14
1865
by: CJM | last post by:
I have a query which produces different results in the Access query builder and in an ASP page (via ADO) An example of the query is: ---------------------------------------------------------- Select 'Ranked' as Source, H.HotelName, H.TelNo, H.URL, H.Location, H.HotelID, Rank from (Hotels H Inner Join PrefHotels P on H.HotelID = P.HotelID) Inner Join Locations L on P.LocID = L.LocID where Rank is not null and Rank > 0 and L.LocID=2
3
5252
by: Jake McDermott | last post by:
We have a few developers that use Oracle 9i (9.2.0.4.0) on their personal workstations for testing purposes. Recently, weve made the decision to upgrade them to WinXP so that they are able to use some other functionalities of the OS, but we are running into a totally odd problem with Oracle. It seems that, Installing Oracle runs just fine, and our ant scripts to build the database work well...but when we reboot the computer, the database...
3
12412
by: Peter | last post by:
Hello, Two newbie questions: 1) I have a javascript file with a function in it. From this function I want to access a variable in another javascript file -which is not inside a function. I have tried many combinations to do this, but has yet to try the right one. How is it done? 2) What kinds of file operations can be done in Javascript (save,
36
16454
by: Thomas | last post by:
after spending countless hours trying, i give up and hope to get some help in here. on server1 i got the web myweb.com with my test.asp. in the test.asp, i'm trying to read a file from an UNC path with a FSO: Set myFile = Server.CreateObject("Scripting.FileSystemObject").GetFile("\\server2\myshare\myfile.txt") this fails with an Permission Denied. here's the deal:
10
3743
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server Error in '/QuickStartv20' Application. -------------------------------------------------------------------------------- Configuration Error Description: An error occurred during the processing of a configuration file
22
3250
by: roadrunner | last post by:
Hi, Our website has recently been experiencing some problems under load. We have pinpointed a particular function which slows dramatically when we have these problems. Normally it should execute in under a second but it rises to about one minute under duress. The code is fairly straight forward with no calls to databases or any other servers. The only dubious thing I can see is that it retrieves several arrays from the Application...
2
2518
by: JJA | last post by:
I'm looking at some code I do not understand: var icons = new Array(); icons = new GIcon(); icons.image = "somefilename.png"; I read this as an array of icons is being built. An element of the array is an object itself but what is this syntax of the consecutive double quotes inside the brackets ?
1
2291
by: pitjpz | last post by:
We have moved our Database to another server. The server it was on used SQL 4 and the new one its on now uses SQL5 the only problem we can find is that when you attempt to delete a record from the DB the following happens: When Deleting a record: Fatal Error: Can't call method "fetchrow_arrayref" on an undefined value at GT::SQL::File::delete_records line 275. Stack Trace: GT::Base (2704): main::fatal called at...
0
9706
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
9579
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
10571
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
10326
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
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4295
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
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.