I want to store (and later retrieve) an array.
How is the simplest and best way to do so?
10 1316
Depends on how long you want to store it: for the duration of a session of over sessions?
For the duration of a session you can store the array in the $_SESSION array. Over sessions you can store in in the database.
It would be easiest to first use PHP serialize() function on the array to make it into a string that can be stored anywhere. After retrieving iy back again in a string variable, you can then use PHP unserialize() function to reconstruct the array again.
Ronald :cool:
No. I don't want is only for that session.
I want it to last at least a week, and on MY server, not HIS system
So, I guess I'll use the serialize(), but how should I store it?
(that was my original question)
Thanx,
And to make things clearer:
I want to store my serialized array somewhere where I can retrieve it with PHP when needed.
What should the code for that be?
A serialized array is just a straight string. So you can store it, depending on the expected length, in a char or (better) varchar data type table column.
Ronald :cool:
So what should the code for this be?
So what should the code for this be?
You will need a database server up and running with relevant access permissions.
Also, php.net has plenty of information on interacting with a dbms, such as MySQL. Just pop in 'mysql' in the search field on http://php.net/ and in the drop down, select "online documentation" and you will have all the information you need.
TheScripts is not a code database, you don't just come and expect code. Make a start, show us what you have done and if you're struggling or need help, people here will be more than happy to assist.
If you do not know anything about storing data in a MySQL database, then you'd better run off to get some basic education for MySQL (and maybe PHP also).
Ronald :cool:
It just so happens to be that I never got into databases yet.
Quote: show us what you've done
Actually, I've already written a full-fledged website using PHP: http://www.thelivingsidrah.com
cool man..,
the simple way is what you prefer and understand to use.
it depends on you, whether txt or database.
I cann't show you how to do this, because this is large problem on simple question, but i'm sure you're really had experience on php to accomplish this.
So my suggestion is,
If what you need is just to store un structured data, using txt is a good simple once.
But if you need to store structured data, so you can manipulate this data (sorting, updated per one data, etc), using database is more simple.
all i had mention is not look from the simple or not the code to write, but it's look from the simple logic to implement....
Atli 5,058
Expert 4TB
I'd be very carefull when using external text files. In my oppinion it would be simpler to just learn MySQL than it would be structuring a decent system on your own.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Chris Cioffi |
last post by:
I started writing this list because I wanted to have definite points
to base a comparison on and as the starting point of writing something
myself. After looking around, I think it would be a...
|
by: Reed L. O'Brien |
last post by:
I see rotor was removed for 2.4 and the docs say use an AES module
provided separately... Is there a standard module that works alike or
an AES module that works alike but with better encryption?...
|
by: Andy |
last post by:
Hi All!
We are doing new development for SQL Server 2000 and also moving from
SQL 7.0 to SQL Server 2000.
What are cons and pros for using IDENTITY property as PK in SQL SERVER
2000?
Please,...
|
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from...
|
by: Bura Tino |
last post by:
Hi,
Going forward, what's better to use
<td height="20">
or
<td style="height:20;">
|
by: ar |
last post by:
If I had a form with one textbox on it and I wanted to populate that textbox
on page load, how could I do that from a global procedure?
I tried creating a separate class file with the following...
|
by: Steven T. Hatton |
last post by:
I just read this in the description of how C++ is supposed to be
implemented:
"All external object and function references are resolved. Library
components are linked to satisfy external...
|
by: intl04 |
last post by:
How do I create a data input form in Access that is external to the
Access database to which it's connected (if that's possible, which I
believe it is)? For example, if someone clicks on an Access...
|
by: sub |
last post by:
I'm using plone primary as a news system for my school.
Now I want to integrate external sources into my plone site.
The page is...
|
by: antonyliu2002 |
last post by:
I know that this has been asked and answered thousands of times. As a
matter of fact, I know that I need to say
If Not Page.IsPostBack Then
'Do something
End If
for things that needs to be...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |