GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Dec-2002, 09:16
pcxgamer's Avatar
pcxgamer pcxgamer is offline
Senior Member
 
Join Date: Sep 2002
Location: South Carolina, USA
Posts: 1,095
pcxgamer is a jewel in the roughpcxgamer is a jewel in the roughpcxgamer is a jewel in the rough
Question

PHP Script


how would I add the text file to a MySQL database?
__________________
If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization.
  #2  
Old 15-Dec-2002, 03:22
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
i have never done this b4 so all i can do is post a URL...

http://www.mysql.com/doc/en/LOAD_DATA.html

...something to read in bed, with laptop and wireless network no doubt. Share what you find out.
  #3  
Old 15-Dec-2002, 08:47
Garth Farley Garth Farley is offline
Awaiting Email Confirmation
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
Wouldn't it be easier to save the PHP script in a text file, and put the filename of the script into the database.

Certainly having a column in the database that can expand dynamically (I think it's a BLOB) to fit whatever goes in, really slows things down. And with a large table full of scripts, a simple SELECT statement will take a while. And the database will end up taking up more space than if you'd just saved each file to the disk directly.

But I'd be curious to see how you get on. So do keep us informed

Garth Farley
  #4  
Old 16-Dec-2002, 02:02
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
reading Garth's reply, I realise that my reply was about something else entirely.

I had assumed you were talking about loading a text file db into MySQL... go figure!

Yeah, like Garth said, you can do either:

load the text directly into a table
load just filename into a table; and include() it
load the php filename into the table; and eval() the file

depending what you decide, then you can insert the data into mysql

PHP Code:

INSERT INTO table (fieldname) VALUES ('$file[i]name/text[/i]') 


  #5  
Old 16-Dec-2002, 23:56
pcxgamer's Avatar
pcxgamer pcxgamer is offline
Senior Member
 
Join Date: Sep 2002
Location: South Carolina, USA
Posts: 1,095
pcxgamer is a jewel in the roughpcxgamer is a jewel in the roughpcxgamer is a jewel in the rough
Need alittle help please, I'm still tring to understand how this is going to work I need a few more ideas. I need a PHP script that will search thourgh a folder on the server for a text file and display the link to that file to the user. Like if I search for cheats for gameA it will display a link to the txt or html file that is for the gameA cheats. The script will only need to handle two options Cheats and FAQs for now. I need alittle help in the direction I need to go to get this script started.

Thanks
__________________
If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization.
  #6  
Old 17-Dec-2002, 02:50
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
why don't you start with something simpler, just work on a script to list your FAQ and Cheats alphabetically - then... tackle a keyword 'search' script.

If you decide to go that way, attach a sample of the file / text that you want to include in your pages and we can discuss the next step.
  #7  
Old 10-Jan-2003, 06:52
Elmseeker's Avatar
Elmseeker Elmseeker is offline
Junior Member
 
Join Date: Jan 2003
Posts: 87
Elmseeker is on a distinguished road
Quote:
Originally posted by Garth Farley
Wouldn't it be easier to save the PHP script in a text file, and put the filename of the script into the database.

Certainly having a column in the database that can expand dynamically (I think it's a BLOB) to fit whatever goes in, really slows things down.


If you want to save a PHP script in the DB you wouldn't use a BLOB type field as BLOB is for binary data such as images. I would personally use largetext, which is what i use on my site for the news. I am not sure of the maximum size of a largetext field but I know it's pretty darn big and can probably handle most php scripts with little or not problems. As for handling the slowdown issue that's easy as well. Simply make sure you have a ID for each then have your select statements use the ID, make sure it's index and unique, that way select calls to the DB won't slow it down because they will only pull the whole row when the right criteria is met, like:

PHP Code:

<?
$id = 1500;
$query = SELECT * FROM yourtable WHERE 'ID' = $id;
result = mysql_db_query("yourdb", $query);
echo $row[1];
?>


This will only pull the row with ID 1500 from the database the rest of the function only uses the ID column which should only be an int, if you have a HUGE site with TONS of rows in the DB maybe ID could be a bigint...good idea to have ID set to unique, index, auto_increment and I usually make mine primary as it is where I do 99% of my queries.
 
 

Recent GIDBlogVista ?Widgets? on Windows XP by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP script to show last referrer url and top referrer to your site jrobbio MySQL / PHP Forum 6 22-May-2006 01:06
[script] Password Protect web pages/site using PHP and MySQL JdS PHP Code Library 0 23-Jul-2003 10:02
All the big PHP script collections that matter jrobbio MySQL / PHP Forum 5 06-Jun-2003 16:14
Have an email sent to you when Google crawls your PHP site jrobbio MySQL / PHP Forum 5 26-Feb-2003 22:38
VALIDATING file types on an PHP upload script? JdS MySQL / PHP Forum 0 02-Jan-2003 07:58

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 21:17.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.