TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-18-2009, 10:48 AM   #21 (permalink)
The Contributor
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
TheOnly92 is on a distinguished road
Default

I think I'm going back to using my own custom method... I'm not too good at SQL programming and somehow SQLite hasn't got some admin panel or something...

So is there any concept which will overcome my problem? When later sessions overwrite all the existing values?
TheOnly92 is offline  
Reply With Quote
Old 05-18-2009, 11:36 AM   #22 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Quote:
and somehow SQLite hasn't got some admin panel or something...
I believe it has a few, http://phpsqliteadmin.sourceforge.net/ being one of them.
Quote:
I'm not too good at SQL programming
Surely it would be far easier to learn basic SQL, its not that hard! much simpler than implementing a flatfile database.

Are interceding updates not going to be an issue?
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 05-18-2009, 11:40 AM   #23 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I really wouldn't use my own custom method. I've tried to do projects where I've maintained my own framework, if I were maintaining my own data storage as well, I'd have collapsed and quite likely have died by now.

Don't, just don't Not if you know what's good for you! Use something that's been around for a while, it's been tested throughout. The less work you give yourself in management, the better. I don't even manage my own framework any more.

Being young programmers though, we do like to think we can manage it all.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 05-18-2009, 01:12 PM   #24 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
I really wouldn't use my own custom method. I've tried to do projects where I've maintained my own framework, if I were maintaining my own data storage as well, I'd have collapsed and quite likely have died by now.

Don't, just don't Not if you know what's good for you! Use something that's been around for a while, it's been tested throughout. The less work you give yourself in management, the better. I don't even manage my own framework any more.

Being young programmers though, we do like to think we can manage it all.
Agreed. I think what it comes down to are 3 things.

1) reluctance to use a DB, hence the need to go flat file. Which now you have to come up with a whole way of accessing/modifying the file in your own custom way which is not a guarantee any success.

2) advanced programmers have already been there done that, so it's quite easy for them to see the positives of using a framework to avoid re-inventing the wheel.

3) curiosity. I personally need to re-invent the wheel so that I can have a better understanding of how things works before I start to fully engage in frameworks etc...plus it would also allow me to appreciate frameworks.
allworknoplay is offline  
Reply With Quote
Old 05-19-2009, 12:53 AM   #25 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by TheOnly92 View Post
I think I'm going back to using my own custom method... I'm not too good at SQL programming and somehow SQLite hasn't got some admin panel or something...
SQL is fairly easy to learn, the initial concepts take very little time. Making your own custom format will be harder, less efficient and far less reliable.

Quote:
Originally Posted by TheOnly92 View Post
So is there any concept which will overcome my problem? When later sessions overwrite all the existing values?
Your options are pretty much SQL, an existing text storage method (CSV, XML, ect) and a custom method made by you. SQL is the easiest.

Quote:
Originally Posted by Enfernikus View Post
Sessions persist until the user leaves the page ( I believe ) or until you destroy them
Partially true. Sessions exist until the machine destroys them. This can be manually or automatically done (the same exact process is called). If Apache works like IIS (it should in this respect), there is a set time limit till the server deletes the session, the session will remain until that period of inactivity has passed unless a manual deletion is called. This is because the server can not really know if you have left the page, all it knows is when you access it.

Sessions are not designed to be shared or constantly modified. Every time the session gets modified the computer has to modify the text file it is being held in (the format is almost plain text). If you have a value that is being modified very often over a large period of time, don't use sessions.
__________________

Village Idiot is offline  
Reply With Quote
Old 05-19-2009, 05:51 AM   #26 (permalink)
The Contributor
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
TheOnly92 is on a distinguished road
Default

Ok, it seems a lot have been asking me to really learn SQL well... Quite reluctant, to be honest, those "CREATE TABLE" thingy really did made my mind burst. I will try SQL again, if I bump into problems, I will be posting here hopefully you will help me.

But the fact is that some of my script's users might be using on their localhost, which means Windows, then I must really need to ask them to install the sqlite extension (which will be annoying because quite many users simply don't know how to read instructions)...
TheOnly92 is offline  
Reply With Quote
Old 05-19-2009, 07:32 AM   #27 (permalink)
The Contributor
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
TheOnly92 is on a distinguished road
Default

What I want to say is I really dislike SQLite, it keeps giving me undefined method eventhough it's documented in PHP's site.

Code:
Call to undefined method SQLiteDatabase::escapeString()
Can anyone also point out my mistake? I'm using PHP 5.2.9 under FastCGI

Code:
$DBHandle = new SQLiteDatabase($this->DBFile);
		if (!$DBHandle) {
			die("Could not access instance database");
		}
		$this->DBHandle = $DBHandle;
$this->DBHandle->query('CREATE TABLE instances (
			id varchar(255),
			Created int(11),
			Name varchar(255),
			Link varchar(255),
			Status varchar(50),
			Size varchar(255),
			Speed varchar(255),
			Received varchar(255),
			Unique varchar(12)
		);');
$query = "INSERT INTO instances (id, Created, Name, Link, Status, Size, Speed, Received, Unique) VALUES
				('$id',".time().",'".$this->DBHandle->escapeString($filename)."','".$this->DBHandle->escapeString($link)."',".
				"'$status','$size','$speed','$received','$unique')";
			$this->DBHandle->query($query);
TheOnly92 is offline  
Reply With Quote
Old 05-19-2009, 10:42 AM   #28 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Try:
sqlite_escape_string

instead, i don't think there is an OOP alternative.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 05-19-2009, 11:41 AM   #29 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Where did you see SQLiteDatabase::escapeString() documented? As sketch pointed out, you'll need to use the function sqlite_escape_string.
Salathe is offline  
Reply With Quote
Old 05-19-2009, 02:59 PM   #30 (permalink)
The Contributor
 
ioan1k's Avatar
 
Join Date: Mar 2009
Location: US
Posts: 76
Thanks: 0
ioan1k is on a distinguished road
Default

Quote:
Originally Posted by TheOnly92 View Post
Ok, it seems a lot have been asking me to really learn SQL well... Quite reluctant, to be honest, those "CREATE TABLE" thingy really did made my mind burst. I will try SQL again, if I bump into problems, I will be posting here hopefully you will help me.

But the fact is that some of my script's users might be using on their localhost, which means Windows, then I must really need to ask them to install the sqlite extension (which will be annoying because quite many users simply don't know how to read instructions)...
Why Not use a WAMP setup?
(Windows, Apache, MySQL, PHP)

MySQL has phpmyadmin and your windows users can install WAMP, and they will be all set.

Using MySQL you don't need to worry about creating tables just selecting, inserting, deleting
__________________
My Portfolio - Work - Need freelance Work?
I've been developing 5 years now, and I learn something new everyday
ioan1k is offline  
Reply With Quote
Old 05-19-2009, 03:09 PM   #31 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Quote:
Using MySQL you don't need to worry about creating tables just selecting, inserting, deleting
You dont need to either with sqlite (edit: once they are created that is), unless you use a memory based database:
PHP Code:
$db = new SQLiteDatabase(':memory:'); 
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 05-20-2009, 04:40 AM   #32 (permalink)
The Contributor
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
TheOnly92 is on a distinguished road
Default

Well, the reason I didn't want to use MySQL has been stated at the beginning of the topic.

http://www.php.net/manual/en/sqlite3.escapestring.php

Isn't that the same for my usage?
TheOnly92 is offline  
Reply With Quote
Old 05-20-2009, 08:43 AM   #33 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

I believe SQLite3 is in PHP5.3.0, not sure though.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 05-20-2009, 09:08 AM   #34 (permalink)
The Contributor
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
TheOnly92 is on a distinguished road
Default

Well, you have a list of SQLiteDatabase methods?
TheOnly92 is offline  
Reply With Quote
Old 05-20-2009, 09:10 AM   #35 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

http://uk3.php.net/manual/en/ref.sqlite.php
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 05-21-2009, 10:47 AM   #36 (permalink)
The Contributor
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
TheOnly92 is on a distinguished road
Default

Thanks a lot, looking into my own problems now.
TheOnly92 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Injection and mysql_real_escape_string Durux General 61 01-29-2013 12:20 PM
Venerable methods and the applications they are commonly trusted in. Village Idiot Tips & Tricks 7 11-06-2008 07:36 AM
Creating a table from loaded data benton General 5 04-20-2008 11:48 AM
The act of sharing your data Wildhoney General 0 12-06-2007 03:31 PM
Tips: PHP security Village Idiot Tips & Tricks 22 11-23-2007 11:17 PM


All times are GMT. The time now is 08:09 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design