Problems With Reading Data From A Text File And Inserting The Data Into DB
Ive been having problems getting this to work for 3 days now. Basically what im trying to do is read from a text file and insert the information into mysql. The text file is in this format:
"LuCyndi@infiniti.com","carol","kellerhals","109 veeder dr","las vegas","NV","89128","702-254-2061","45" "the_prophet@att.net","a.","cohen","6794 e. bonanza rd","las vegas","NV","89110","702-463-6569","55"
I understand how to open files to read but im having problems turning each set of data into an array so i may insert it into mysql. If someone could please help it would be appreciated.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Inserting Text File Data In DB
I have a text file that looks like this: 45 http://www.site.com/referrer.php Windows XP IE 6 48 http://www.site.com/referrer2.php Mac OS X IE 5.2 53 http://www.site.com/referrer3.php Linux Netscape 7 What code should I use to insert each group of information in a row, for example I want the text file above to be inserted in a table like this: ID || Referrer || OS || Browser 45 || http://www.site.com/referrer.php || Windows XP || IE 6 48 || http://www.site.com/referrer2.php || Mac OS X || IE 5.2 53 || http://www.site.com/referrer3.php || Linux || Netscape 7
Reading File Data
i am trying to read ogg metadata by opening the file and looking for the tag data, i can manage to echo out the vorbis header, but the commend fields wont echo out, i get random characters-buti can see the data in the file (with a hex editor) whe i try and read the data for album name using fread($file,x) ; and echo it out, its not equal to the album name?
PHP - Reading File Data Into Memory
how much data can I store to memory when my PHP script is executed? f.e.: 1. step: read data from file (1 MB is possible? ) 2. make all needed changes 3. write data back to file
Reading File With Fixed Width Data
What's the best way to read a text file that's delimited by fixed width columns? I'd like to read from the line, beginning at position 7, the next 10 characters (Name field), then beginning at position 27, (skipping the word Address) the next 20 characters (Address field), etc. Last field needs to go to the end of the line since it's a variable width.
Reading Data From A Simple Binary File
I've read some discussions, searched Google, tried pack, unpack, bin2hex, explode, implode, and I just can't figure out how to convert this data. I am trying to read a file with the following format (two examples). 41 6D 74 72 61 6B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 75 05 1A 00 41 6D 74 72 61 6B 20 4F 6E 6C 69 6E 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8F 05 2B 00 The first 28 bytes are a 00 terminated character string (in this case "Amtrak" and "Amtrak online") Next are the location (offset) of an entry in another file (2 bytes), followed by that entry's size in the file (the next 2 bytes). The above examples are key entries in an index file pointing to variable sized entries in a data file. I am using fread to put each field into a string variable (28 bytes, 2 bytes, and 2 bytes). The binary values are "Little Endian" (right?). In other words 75 05 is really x0575 and 1A 00 is really x001A. I am having the most trouble with these (I've already used bin2hex, but I don't know how to convert the little endian to decimal.) 1. I want to strip the 00's from the string. 2. I want to convert the location (offset) into an integer variable. 3. I want to convert the size into an integer variable. I am going to use location and size to fseek and fread the entries in the data file into another string. My actual goal is to transfer this data (the string and it's associated, variable sized text field) into a MySQL database. My guess is (was) that this is easy, but I just can't figure it out.
Convert Php Data Into Text File?
I have a php file that gathers data from a specific website. I am then using that data (numbers) in a different application. The only problem is the html formatting. I just need the numbers, but I'm getting all the html tags with the data. Is there a way for me to have the php file output in to a seperate plain text file?
Import Data From Text File?
I'm not sure how to do this, can anyone steer me in the right direction? I have a DB table called 'vehicles' It has three columns: ID ¦ vehicle_type ¦ vehicle_make I have a text file containing a list of the vehicle types and makes. Example: Austin Healey - 3000, Sprite Austin Passenger - 1800, Allegro, Ital, Maxi, Mini Bentley - Corniche, Mulsanne, T Series How would I import this into my database?
Retreive The Data From The Text File
I get the data as a plain text iinto my php file. I have some images in the text file, so how I should make it look good (layoput)and show the images too.
Saving Data To Text File
I have a php form that I'm trying to save to a text file to be accessed by flash later on. I'm able to get the text file created but nothing ever writes too it. I have 29 variables that need to be recorded to be accessed later . . . can someone help me out here? Following another tutorial to make sure i had it set up correctly (that's still debatable) here's the form code:
Retrieve Data From Text File
I have a text file (accounting information) which contains a lot of information and some of this information (numbers) I want to retreive (import to a php script) and be able to use some figures in calucations etc. Here is a piece of the text which shows the build up of the information I want to use: Code:
Choping Data From Text File
I have a form where people will select 1 of 5 choices for class president, and then vote for any number of their favorite courses (for now). What I need to do is save the info to a text file, which I have got working fine. But then I need to read the information and cut it up so I can tally up the results via counter arrays. Here is the code for my php script: .....
Finding Double Data In Text File
I am working on this e-mail newsletter subscription thing and I am storing the data in a txt file (mySQL is better, I know but I want it to be compatible with non-mysql systems). Off course I don't want any e-mail adresses appearing twice in my list (the list looks like this: someone@somewhere.com, blah@bla.com, et cetera). How can I prevent this?
Form Data Inserted Into A Text File
I am wondering if it would be possible to create a form and using php have the form data inserted into a text file. The data would have to be inserted in a given way.
Need To Create Drop Down Box With Data Pulled From Text File
Trying to make a drop down box like this example: Dog Cat Bird But sometimes I will need to update it...and add/remove names from the list. I want to do it fast and easy and I don't want to use a MySQL Database. I'd rather use a text file...can that be done? I would keep the info in a text file and then push it to a drop down box via php and html.
Suggestion Needed On Data Storage Format In Text File
The project I am developing doesn't involves database. I want to parse the mailbox file (.mbx) and store the summary in the text file for fast retrieval and display of information in the Inbox page. The sugegsted format are as: #1 ID [4 bytes]: Subject [100 bytes]: To Address[100 bytes]: From Address[100 bytes]...etc... #2 Instead of preassining fixed size to variable (as actual data may be much less or can grew to more), we can store the values continuously, seperated by some unique seperator (#|#, *#*, ...) 1324#|#Hi, How are you#|#me@google.com#|#you@google.com#|# ... and so on Which of these will be the efficeint one (as there will be frequent insert/delete/update of the individual information, eg. set message as read ..., delete message ..., new message ...) Also please suggest on how to determine the variable size (100 bytes as in #1), and assign the size to the variable accordingly and read it (differentiate multiple variables) when required.
Inserting Data Into A Row
I’ve got a table of three fields (id, name and comments) that contain 30 rows. Each row contains data in the two first fields (an id and a name). The third filed is empty. When a user accesses my page they can select one of 30 names from a drop down menu. After they’ve selected a name the user can write a comment about the person he/she selected. How can I insert the comment from the user into the comment field related to the name selected?
Inserting Data Twice
I'm working with a database now, and I have an error here, somewhere. The first time the user hits submit, the data goes in once, the second time the user hits submit, the data goes in twice. I don't know why. PHP Code:
Inserting Data
how to insert select and view data from a database but i cant get it to work, it says that the data has been insterted but when i go to index.php nothing is shown, maybe it is my database? wht should the code be to make a suitable database? Code:
Inserting Data Only ONCE
I currently have the following: $zip = $db->escape($_GET['zip']); $db->query("INSERT INTO zipdata SET zips = '$zip'"); However, every time that page loads it is inserted. Is there a way to make it only insert one time per user.
Inserting Data Into A Table
I would like to know if there is anything strange about the script below(I have only just started to learn php so there may well be!) Although it seems to work, occasionally it doesn't just insert a single row into the data base, instead 2 or 3 duplicate rows end up in the table. Could the explanation be that I tried this morning to create a table and forgot I already had one with this table name in the database. Would that have damaged the table in some way making it misbehave! I have commented out the bit about creating tables as I only want to insert data with this script at the moment. One other thought occurs to me, is the problem due to my host freedom to surf as its only a free host and I expect you get what you pay for(or don't pay for in this case). I have subscribed to a pay host http://www.phpwebhosting.com but I am unable to use the database that they have provided because they have informed me that I must use a telnet shell to log into my database and I have absolutly no idea what this is(is it in my Win98?) or do I need to go and get one. I am still waiting for this host to email me back with some help. If there is anyone out there who could tackle all or some of my problems I would be very grateful indeed! One last thought - I think there is something very strange going on as sometimes when I visit my database, there is less entries in this table than last time, some have been chucked away and my id entries are all out of order now, something like 1,2,3,11,5,7,12 - the last insert had id = 12 next to it and somehow another duplicate has sprung up id = 11???????? Whats going on please! <html> <head> <title> Connecting to Mysql server at ISP host</title> </head> <body> <?php $Host = "db.davegraham.f2s.com:3306";// Set the variables for the database access: $User = "p0c79"; $Password = "********"; $DBName = "p0c79"; $TableName = "Jokes2"; $link = @mysql_connect("$Host", "$User", "$Password"); if (!$link) { print("<P>Unable to connect to the " . "database server at this time.</P> "); //note how 2 strings have been concatonated exit(); } else { print("Your now connected to the Mysql server at the host ISP.<P> "); } if (! @mysql_select_db("$DBName") ) { print("<P>Unable to locate the $DBName database at this time.</P> "); exit(); } else { print("The database $DBName has been located.</P> "); } /* $sql = "CREATE TABLE $TableName (ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, JokeText TEXT, JokeDate DATE NOT NULL )"; if ( mysql_query($sql) ) { print("<P>$TableName table successfully created!</P> "); } else { echo("<P>Error creating $TableName table: " . mysql_error() . "</P>"); } */ $Query="INSERT into $TableName VALUES(Ɔ', 'hello hello hello!', ��-08-08')"; if (mysql_query ($Query)) { print ("The query was successfully executed!<br> "); } else { print ("The query could not be executed!<br> "); } mysql_close($link); ?> </body> </html>
Inserting Data Using A Form
I created a script to allow the user to select the number of images to enter. After that the script generates the entry fields dynamically. The final step is entering all images into one column in the db called images. The problem is i got it to work using an advice from someone at devshed forums to use some additonal script. Please see below. 1) HTML File that allows you to enter the number of text boxes to create for each image you want. <FORM METHOD="POST" ACTION="do_show.php"> <P><strong>Number of images:</strong><br> <INPUT TYPE="text" NAME="num_imgs" SIZE=5></p> <P><INPUT TYPE="submit" NAME="submit" VALUE="Go to Step 2"></p> </FORM> 2) PHP file that shows the created text boxes for you to enter the names of these images:
Inserting Data Into 2 Tables
I've got this products page form and what I have is two tables to insert the data into, about_products,about_urls. What I am trying to achieve is to insert info into about_products table and the URLs associated for that product. The thing is, is that I'm having trouble getting to insert the URLs for that product. Note that the product form is duplicated 8 times. PHP Code:
Inserting Data Into A Table.
I keep getting a parse error with this code. What am I doing wrong? The SQL statement works in MySQL. Is there something wrong w/the way I'm decaring my PHP variables? Code:
Inserting Data Into Mysql
I have a simple loop include '../php_library/connect.php' include '../php_library/opendb.php' $conn=mysql_connect($host,$dbuser,$dbpass) or die ('Error'); mysql_select_db($dbname); //Open the file $fp = fopen($src,"r"); //for each line in the file while ($row=fgetcsv($fp,10000,'')) { //Get line $sql_insert="INSERT INTO ..."; if (!mysql_query($sql_insert,$conn)){ OutputError($sql_insert,$mysql_error()); $FailedCount++; } else {$InsertCount++;} } It works fine for the first couple of hundred or so rows but the stops - no errors, it just stops mid-loop. I'm guessing some sort of buffer problem (needs flushing?) but it is a guess. I'm running this all locally - XP, Apache2, PHP5, mySQL 4.1
Inserting Some Data Into Database..
The code I have at the moment creates directories (mkdir) and copys files into them. This seems to work, but I need the variables "$mypath" and "$newfile5" to be inserted into my database. But it won't. It enters the other data such as name and description and creates the folder. Code:
Inserting Data Into MySQL
I am having a problem inserting data into MySQL what can be the problem ?? $SQL_insert = "INSERT into borrow VALUES ('','$bok_id','$bok_nam','$stu_id','$stu_nam','$DOI','$due_dat','','')"; mysql_query($SQL_insert)or die("Couldnot insert"); Database structure: The first column is auto increament and last two columns can be null. Date is also in : m/d/y format so MySQL should accept tht as it is.
Inserting Large Data
i have this form that we will need to fill in and the info gets entered into a DB. what is the easiest way of inserting this data into a tbl? is there anyway that i can check that the same driver has not been entered twice?
Inserting Data From Query
I have a simple query $sql = "SELECT * FROM siteusers"; $query = @mysql_query($sql,$connection) or die(mysql_error()); while ($row = mysql_fetch_array($query)) { print $row['email'].'; '; } This basically produces something like; email@domain.com; myname@domain.com; How can I define these as a variable such as $allemails; So that I can insert it into a INSERT query. And lastly, how can I remove the symbol ; from the last row returned.
Inserting Data Into 2 Tables
I'm trying to insert data from a form into 2 tables, and I just can't find out whats the matter with this. The following is the insert function, which works fine inserting into the product table, just no information goes into the track table from the form. Code:
Inserting Data Into Mysl
i have this piece of code below working great when echoed out displays the files like it should, they can be upto 100 lines depending, what i wanted to do is store ALL the date for "$output" & "$parts" in mysql but it only stores the first line not the rest, if i put my insert query in the foreach it inserts the files but makes an entry for each file (instead of the whole lot in the 1 field)Code:
Problems Inserting Data Into Mysql
I am trying to load data into the mysql database from a tab delimited text file. The Text file has 15455 rows, so I should expect that many records to be created when I load the data into the table. However it only gets to 12692 records, and I get 15455 warnings (the expected amount of records). Code:
Inserting Data Via Website Form
I am trying to create a membership form that inserts data into mysql. I am using phpmyadmin, mysql 5.0 through M6.net I belive I have the connection set up right, but I am a newbie and self-taught. So, here is the form and script Code:
Date Format When Inserting Data
I am getting a date entry through POST by a form byt the format enetered by the user is 'dd/mm/yy' .... how could i use MYSQL PHP syntax to insert the proper format as it is default in the table in my database. which function is it?
Arrays And Inserting Data In To The Database
I have a form that uses two arrays one get's a list of courses from the database and one creates dates... i have two questions 1. how do i get the $i and $d value off of the arrays to insert in to the database, but still have each know they belong in the same row? 2. how do i change the dates from a multiselect dates ie, Jun 3, Jun 6, and Jun 12 to 'Jun 3, 6, 12' here is the snippet of code from my select page. $numposts is a value selected on an earlier page. Code:
Inserting Empty Data Into Mysql
I am creating an interface for my wife to keep track of what cross stitch threads she has. I have created a text area so she can enter a bunch at a time. I am trying to get the script to skip over blank lines. Code:
Inserting Data Into A Users Row In Mysql
i'm not sure if this is possible but this is what i'm attempting to do: 1)I Have made a registration page for a user to fill in and submit <-- ok 2)Once they do they can login to thier account <-- ok 3)the minute they are in thier account they can upload a photo/avatar and it submits the path/filename e.g to the database "grahamspicture.jpg" for example. but what i'm not sure about is HOW to post that logged in users data back into the mysql database, once that particular user logs in how to make mysql know to post the path in grahams mysql row under photo (i hope that made sense) Code:
Inserting Checkbox Data Into A Database
Typically, checkbox inputs have a name value of an array (something like <input name="options[]" type="checkbox" />). Is there an easy way for me to extract the values of such an array and insert them into the right database column? Or should I just bite the bullet and give each checkbox input a unique name so I save myself some confusion/readability?
Inserting Data From A Form Into Two Tables
I am trying to get the logic in inserting data from a registration form into two tables in mysql database. One table (name) has a primary key (name_id) and the other (address) has a primary (addr_id) and foreign key (name_id). Inserting into the tables is not a problem but I want to make sure that if I reference to the name and address table, it will retrieve the probably address with the name. Do I have to first insert into the name table and then get what the name_id is? Next, insert that name_id into the address table along with the rest of the info? I hope this is clear enough.
Inserting Data From A Sql Database Into An Array
I am currently working on a project where I need to put information from a sql statement into an array. Currently I can get one row into the array, but the rest aren't showing. I have checked, and all of the information is getting to the array, but I can only get one row to show up. Here's the code: while(($row = mysql_fetch_array($result))) { $info=array($count=>array('line1'=>$row["first_name"], 'line2'=>$row["last_name"], 'line3'=>$row["product"], 'line4'=>"$".$row["date"])); $count++; } I'm trying to get this array to hold multiple rows from the sql statement, but when I display the array, I can only get one row out of it.
Inserting Data Via Browser(textarea) Into Database
I just wanted to make something that creates html-code which should be inserted in a mysql database. The user should type text in a textarea. When the user submits the data, all enters should be translated into "<br>" and it would be nice if the user could also insert links ( "<a href="..." ) in the formular. Does someone knows a good, very simple script? There are wysiwyg editors on the net, but I don't need to modify fonts, colors et cetera. The most important thing are the "<br>" tags which should be generated.
Parsing - Reading Data Within A Tag
I am new to XML and PHP and have a question that I hope someone could answer. Some background on my problem.I am receiving an XML message over TCP/IP and need to access data within the tags of the message. Message example: <message title="begin" no="1"><description>Start</description></message> Now I know I can get the data from the description tag by: $xmlstr =<<<EOT <message title="begin" no="1"><description>Start</description></message> EOT; $xml = simplexml_load_string($xmlstr); echo ($xml->description[0]); My question is, how do I access 'title' or 'no' ? Is it possible?
Help Req. Reading Data From MySQL Db With PHP
I have PHP code (below) which reads data from a MySQL format database. The problem I am having is trying to find out when the last ID entry was made. When the script is executed, the $gbID is supposed to be read and display the last entered ID number ($How_many_entries) - the ID number is entered / updated automatically in another PHP script which deals with data entry to the database. But instead of displaying the result of the query, it displays the ID number ($How_many_entries) as "Resource id #4", and looking around the search engines, no page makes particular sense as to what I've done wrong. Does anyone know how to get the $gbID number from the database and into $How_many_entries so I can perform some math work on it? <? $DatabaseName = "Guestbook"; $table_to_look_for = "entries"; $connection = @mysql_connect("localhost") or die("<B>Could not connect to MySQL: </B>".mysql_error()); mysql_select_db($DatabaseName); // get all tables in the database $result = @mysql_list_tables ("DatabaseName"); // Display database entries in reverse order (remove 'DESC' to have forward display of results) $sql = "SELECT gbID, gbDate, gbIP, gbURL, gbName, gbComment FROM $table_to_look_for ORDER BY gbid DESC"; $result = @mysql_query($sql, $connection) or die("<B>Problem reading from database: </B>".mysql_error()); while ($row = mysql_fetch_array($result)) { $gbID = $row['gbID']; $gbDate = gmstrftime('%A %d %B %Y at $T',strtotime($row['gbDate'])); $gbURL = $row['gbURL']; $gbName = $row['gbName']; $gbComment = nl2br($row['gbComment']); $display_entry .= "$gbID:<BR><B>Posted on: </B>$gbDate <B>IP: </B>Logged<BR><B>Posted by: </B>$gbName<BR><B>Personal website: </B>$gbURL<BR><B>Comment: </B>$gbComment<BR><BR>"; } $sql = "SELECT last_insert_id($gbID) FROM $table_to_look_for"; $How_many_entries = @mysql_query($sql, $connection); // $How_many_entries = $How_many_entries / 5; echo "Entries: $How_many_entries<BR>"; etc....
Reading C Data Structures
I have a file duplication progam I wrote years ago in C on a Unix system. I open up zip files and store CRC info in my own database. It's a great application for php/mysql and I would like to learn php/mysql in the process of moving it over. Can someone tell me how you would read the header (data structure information with all the fields) on a zip file (in this case its the localheader right after the signature), so that all the fields of the structure land nicely in an array in php? I'm attempting to use freads/fseek to each field and this just can't be right. Doesn't matter what data structure I just need to know the most common method you use to open a file in read blocks of data and unpack them back into a data structure.
PHP Inserting Extra Data At Start Of Response Body
PHP version: PHP5 Server version: Apache 1.3 and 2.0 (observed on both version) Platform: observed on Darwin-8.6.0/PPC and FreeBSD-6.1/i686 example: ===== HTTP/1.1 200 OK Date: Fri, 30 Jun 2006 09:24:48 GMT Server: Apache X-Powered-By: PHP/5.1.4 Content-language: en ETag: W/"blogurk_wiki:pcache:idhash:1-0!1!0!0!!en!2--20060114114008" Vary: Accept-Encoding,Cookie Expires: -1 Cache-Control: private, must-revalidate, max-age=0 Last-modified: Sat, 14 Jan 2006 11:40:08 GMT Transfer-Encoding: chunked Content-Type: text/html; charset=utf-8 21af <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> <head> <meta http-equiv="Content-T... ===== Things I've noticed: - browsers don't seem to mind it - I've only seen hexadecimal characters - only changes when page content changes (checksum of some kind?)
Inserting Data Into A Table With Auto Increment In One Field
i have a table with several fileds in and with the first one being an auto increment field. I want to know what my SQL query should be when inserting data. Here's my current one: Code: $SQL = mysql_query("INSERT INTO $usertable2 VALUES('$subject', '$newstext', '$date', '$usrname')"; The auto increment field is the first in the table and is called 'postid'. can someone give me the correct query please? also do i need the first entry in the table to be a blank one with just the postid entered at one?
|