Importing Data To MySql From Web Page
I'm using Drupal(a CMS), along with MySQL and PHP to import data into a database. I'm trying to import a bunch of sentences on one page into the database, but each in their own row. For example:
News
-----
Brand new site
New employee hired
New work acquired
Basically, I need to know how to pull those into the database as one row each, instead of pulling all three elements into the database in the same row. They're all stored in a $content tag, b/c I wrote the page in PHP. So, any ideas on how to make it, so I can insert the $content into the database, but at a line break, I need to insert a new row?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Importing Data Into Mysql
I'm starting working on a new project where I'll have to allow users to upload and import tab-formatted text files into the db. Should I use the LOAD DATA INFILE from PHP or write a custom procedure?
Importing To Mysql Without LOAD DATA LOCAL
I've just gone through the learning curve of realizing most virtual hosts have "LOAD DATA LOCAL" disabled :( I have a two meg delimited ascii file I need to import on a regular basis (26 fields) Anyone have a nice import routine using fopen they are willing to share before I attempt to hack one out myself? I can't seem to find such an animal out there (though some are close). Such a shame, from what I have read, load data is much faster...
Importing A Flat Pipe Delimited File Into A MySQL Data Table
I have done this in perl but eeew I don't want to use perl anymore. I want to be able to take a flat file that looks like this: mbriones@...|Marian|Briones bobsmith@...|Bob|Smith janedoe@...|Jane|Doe (etc) The table has more than 3 fields, so I'd want to process the flat file and then do an INSERT into mailinglist SET field=$value for each line. Does someone have a nice way for me to do this? The flat file will be uploaded to the server via a form (copy) and then be processed.
Importing Data
I have this file cvs that's roughly 2.5 meg. Right now, it uses a function like this to import the data into the table. PHP Code:
Importing Form Data To Ms Access
Does anyone know if one can import a web form data into ms access db? Does the ms access db have to be on the same server as the web form?
Importing Large Amounts Of Data Via File Upload
I was wondering how anyone here deals with move large amounts of mysql data to be uploaded to the server? Large as in 75MB CSV file. I have a client who wants to admin there database with 15,000 users. They manage all data offline and want to upload to the site for display purposes only. My server has 5MB php file upload limit. I really do not want to up this limit. What I am wondering is how does cPanel or PHP MyAdmin get around this upload limit using php scripting?
CSV Importing To MySQL
Well I had the last script working perfectly. Except sometimes we rearrange the CSV "headers" so a field may be in one place on one file and another place on another file, yet they are the same thing. I've tired about 30 different scripts and none of them work at all. For example: Csv file looks like: work order,client name,start date,end date 7283728,"name,client",02/07/07,04/02/07 that is just the test file I've made up. I found out, the hard way, you cannot have spaces in your database fields. So what I am trying to do is take that first line, replace all spaces with an _. That away database fields can be like work_order and in the CSV file also. I tried using Code:
Importing Xml To Mysql
i am using this piece of code to import an xml file to mysql. $feed[$key] = $info; is causing the script to only return the last element of the xml file. I would like to return all elements but cant find a way to do so, <?php include 'library/config.php' include 'library/opendb.php' $file = "my-xml.xml"; $feed = array(); $key = ""; $info = ""; function startElement($xml_parser, $attrs ) { global $feed; } function endElement($xml_parser, $name) { global $feed, $info; $key = $name; $feed[$key] = $info; $info = ""; } function charData($xml_parser, $data ) { global $info; $info .= $data; } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "charData" ); $fp = fopen($file, "r"); while ($data = fread($fp, 8192)) !xml_parse($xml_parser, $data, feof($fp)); xml_parser_free($xml_parser); $sql= "INSERT INTO section ( "; $j=0; $i=count($feed); foreach( $feed as $assoc_index => $value ) { $j++; $sql.= strtolower($assoc_index); if($i>$j) $sql.= " , "; if($i<=$j) {$sql.= " ) VALUES ('";} } $h=0; foreach( $feed as $assoc_index => $value ) { $h++; $sql.= utf8_decode(trim(addslashes($value))); if($i-1>$h) $sql.= "', '"; if($i<=$h) $sql.= "','');"; } $query=trim($sql); echo $value; if (mysql_query($sql)){ echo "success in table creation."; } else { echo "no table created."; } echo mysql_error(); echo $sql; ?>
Importing Text File Into MySQL DB
I'm writing a script to import a text file with fields delimited by ~ into a MySQL DB. I'm trying to import everything into an array first, so that one array row = one record row. Here is some dummy data, with the 񟐚' record having a couple of new lines where a new paragraph is. Note the other records have NULL in the same field: PHP Code:
Importing Excel Into A MySQL Database
i have an excel file I want to read into a database. I found a tutorial which says to save the file into a xml file, then it basically gets all the data out, and puts it into an array Code:
Cant View Data On My PHP Page From MySql DB.
Im working on a character generator for a PHP game Im trying to get going but Im having trouble getting data from my mySql database. I created the table and added all the columns using this file:
Importing A Field From MySQL Into A Variable In Flash?
I have a query that is giving me the field that I require from my database using PHP. What is the best way to import this variable into flash? Can I echo the number out on the page and have Flash import it that way? Could I use the Load Variable command? code:
Importing Excel File Into Mysql Database
I need help regarding importing excel file into mysql database.I am using PHP 5.0.2, mysql 4.2.13. I need code for importing excel file into mysql database and what will be the steps for it.
Populate A Calendar Page With MySQL Data
I'm trying to figure out the best way to populate a Calendar page with data from a database. I have the code that will generate the Table with Days of the week, but I'm at a loss on how to populate this with data from a database. Do I build the calendar and then for every day that I generate a cell, query the DB or should I load the DB in an Array and compare that to the date of the cell?
Simulate Send Data With POST And Get Data From A Web Page (whith A Session)
I'd like to get text of a webpageB that I reach by putting a login and a password in a webpageA. I mean: I'd like to get text of a WebPageB with a php script. But before I can see WebPageB I have to autenticate myself in a WebPageA writing my login and my password in a form, the host recognise me and (by session) let me see the WebPageB. The question is: 1)how to simulate send data (login an password) in form with a PHP script? 2)how to navigate in a Web usin the same session?
If Value =1 Direct To Page Otherwise Show Data On Page
In the member account area there is a button saying (list) when the member clicks this they are redirected to add.php here i am wanting to check if a members account is limited, if it is direct them to a page saying you must pay your bill. if its not display the info on the page. in the database there is a field called limited which is tiny in if its not limited the value of the field would be 0 if it is limited the value would be 1.
Comparing Form Data To Mysql Data
Im interested in building a script that would take form data, a variable like an address, and compare it with a known address in a mysql table (called addresses), then if there is a match log the address information in a separate table called (addresslog), and return the visitor to a certain page. If there is no match between the address entered in the form and known addresses then the information is still logged into the addresslog database but the visitor will be sent to a different page. I'm still new to this, and am working through the logic and the syntax, but I believe I'm close. It's still not working, I have all of the proper tables, maybe I'm way off with the coding so I thought I would seek out some expert advice. Here's the entire script with as much explanation as I could give. PHP Code:
Importing PDF Or EPS
Does anyone know of a way to import an existing PDF or EPS for editing without the commercial PDI library?
Importing Pages
I've written a content management system that I'm now selling to my customers. It's very nice when we have a blank canvas of a site, but a pain in the arse when there is already a site in place. What I'm in the process of *trying* to put together is a script that would do the following: A simple form where you put the address of the site with the static pages The script then spiders through the site, takes everything between <body> and </body> and chucks the rest away It would then take out all class definitions and all embedded styles like font tags etc but leaves tables, <p> <H?> etc This would leave a very plain page of HTML that would be inserted into a database. CSS would control the fonts etc. I'm aware that there would need to be some tidying up if there was any javascript or anything and also some basic formatting. What I want to know is 1. Has it been done and, if so, where might I find something like this 2. Might it have any commercial value to other developers? Regarding 2, I'm thinking how much time something like this might save me if I have to convert anything more than a few pages of static HTML into something that I can put in a database.
Importing SQL Files
is it possile to import data from a sql file which has been exported from another database without using something like phpmyadmin ? Or must it be done using phpmyadmin. Also is it possible to just export data without having to use phpmyadmin or similar?
Getting Data From Another Page
Is there any way I could get the information from this page (http://www.domain.com/rankcapture.php?name=dylandcor2&check=true) such as level and experience into a variable so I can use it to create an image. The page that is linked isn't mine, so I don't know how it is set up. I know how to create the image, I just can't seem to get all of the data out of the page.
Import_request_variables Isn't Importing My Changes To My Globals
The server I'm running my PHP on has "magic_quotes" turned on, so all the input I get (from GET, POST, and cookies) is escaped with backslashes. I don't want this (I handle my own escaping, and I need to be able to work with unescaped strings), but I'm not allowed to change the setting on the server, so I need to figure out a way to "undo" magic quotes. This code itself works... function stripslashes_array($v) { return is_array($v) ? array_map('stripslashes_array', $v) : stripslashes($v); } if (get_magic_quotes_gpc()) { foreach (array('POST', 'GET', 'REQUEST', 'COOKIE') as $gpc) $GLOBALS["_$gpc"] = array_map('stripslashes_array', $GLOBALS["_$gpc"]); } But my problem is that I then want to use import_request_variables to bring any form data into the global variable space, and that's not reflecting the changes I just made to the globals... in other words, if after that code I say: $foo = "GLOBALS["_GET"]["test"]; import_request_variables("gp", "in_"); $bar = $in_test; and I submit the page with "test" set to a'b'c, then $foo will be a'b'c while $bar will be a'b'c. How do I get the stripslashed values into my global variables without having to stripslash each one individually?
Importing With PhpMyAdmin Error.
I've been testing import csv files with PHP. Well it's going ok, I guess, when you save with Excel everything works fine. The output .csv file is from another piece of software, and it appears to be completely fine. Look at this: Line [1] from Excel saved CSV under "date" is this. 59:04.0 Line [1] from Software saved CSV under "date" is this. 2007-06-14 11:59:04.0 Excel takes out most of the date/time. When it is almost taken out it imports with PhpMyAdmin just fine. Well I need that date. For some reason when that date/time is complete MySQL kicks it back. Know the weird thing, I can go into PhpMyAdmin and insert just "2007-06-14 11:59:04.0" into the "date" column. So, this completely makes no sence why MySql is kicking it back. When I compare both csv files they are exactly alike, except the date; yet, there is no problem...anyone have any idea how to fix this? Or maybe a loop around it using PHP. I've got a class file that imports the Excel CSV just fine.
Using COM Objects Or Importing To Outlook
I've been asked to look at developing a web-based system for tracking forms. In itself, it is fairly simple. However, one item they want to look at is Outlook integration for tasks. We use an internal exchange server and I have read about being able to use COM objects to write tasks for Outlook from PHP. However, I'm having difficulty with this part. The script I do have is timing out and documentation on using COM objects is fairly sparse. Should I be looking at something other than PHP? Code:
Page Keeps Caching Old Data, How To Fix?
i have a php page that has a series of check boxes in it and you press the update button after unticking some boxes and ticking others. after the page updates the changes actually take place in the database but the page displays the old state where it was before you ticked and unticked the boxes. as soon as you press Ctrl + F5 it actually updates the page to what is in the database. how can i fix this so when i press the update button it refreshes and doesnt cache the old state? i have the following in the header but it dont seem to work, is there anything else i need to do? <meta http-equiv="pragma" content="no-cache"> <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
Change Data On The Same Page To Something Else
I'm trying to change data on this line of code using a drop down option box. map.centerAndZoom(new GPoint(-79.89505, 40.85708), 10); When the page opens I want the above data to be used. I want to use a drop down menu to select a different radius. Lets say 30 miles. I want to update the page so that the above line of code will update and look like this. map.centerAndZoom(new GPoint(-79.89505, 40.85708), 30); Here is some sections of code I am using. <form action='<?php echo $_SERVER['PHP_SELF'];?>' method='post'> <select name="radius" class="selectBoxes"> <option value="20">20 miles</option> <option value="30">30 miles</option> <option value="40">40 miles</option> </select> <input type='submit' name='submit' value='Click To Update Map'> </form> <script> map.centerAndZoom(new GPoint(-79.89505, 40.85708), 10); </script>
Display Data On Page
Ive got my page set up correctly as far as getting data into the database goes however I am not sure how to display it all on the page. Basically I have a news table: news_id, club_id, title, news I would like to display all the news items associated with the club that the user is logged into. Id like each news item to be separated so that its easy to identify they are different news items e.g. __________________________ $title $news __________________________ $title $news __________________________
Extract Data From A Web Page?
with PHP, can somebody direct me or give me some insight on how to go about extracting data from a web page. Say I want to pull sports statistics from a page.. how is this done?
Duplicate Records In DB When Importing From CSV File
The code below is used to grab each row from a CSV file (except the first row) and insert it into a database, as long as it's not already in the DB. If I echo each row's data, it appears only once on the page. But, for some reason it inserts each row into the database 3 times. The code that echos the data, and the DB insertion code all appear within the same for loop. The database insertion code (below) works perfectly in another script. It's just copied/pasted into the for loop. $row = 0; $handle = fopen ("some-file.csv","r"); while ($data = fgetcsv ($handle, 1000, ",")) { if($row == 0){ // set the varible array $num = count ($data); $csvNames = array(); for ($c=0; $c < $num; $c++) { $csvNames[$c] = $data[$c]; eval("$" . $data[$c] . " = array();"); } $row = 1; }else{ $num = count ($data); $row++; for ($c=0; $c < $num; $c++) { $buildEval = "$" . $csvNames[$c] . " = "" . $data[$c] . "";"; eval($buildEval); echo $buildEval . "<br>"; // this properly displays only one row's data from the CSV file, then displays the next row in the CSV file when it loops again. // BUT FOR SOME REASON, THE DB CODE BELOW INSERTS EACH ROW FROM THE CSV FILE 3 TIMES. // Set variables with current date and time to be inserted into DB later $appDate = date('Y-m-d'); $appTime = date('H:i:s'); // Prepare the phone numbers for easy input into the database further down this page. $fHomePhoneCombined = $fHomePhone1 . "-" . $fHomePhone2 . "-" . $fHomePhone3; $fBusinessPhoneCombined = $fBusinessPhone1 . "-" . $fBusinessPhone2 . "-" . $fBusinessPhone3; // Connect to the database $db = mysql_connect ("localhost", "username", "password"); mysql_select_db ("mydatabase"); // Check to see if the record is new, $newRecord = 1; $queryNewRecord = mysql_query("SELECT * FROM cust_test WHERE first_name = '$fFirstName' AND last_name = '$fLastName' AND email = '$fEmail'"); if (mysql_num_rows($queryNewRecord) > 0){ $newRecord = 0; } // If it's NOT a new record, insert the contents into cust_test_bad DB // I'll insert this code later. It's not important for this test. // Write the information to the customers table, if it's a new record. if ($newRecord == 1){ $query = "INSERT INTO cust_test SET application_date = '$appDate', application_time = '$appTime', first_name = '$fFirstName', last_name = '$fLastName', email = '$fEmail', address = '$fAddress', state = '$fState', zip = '$fZip', home_phone = '$fHomePhoneCombined', best_time_to_call = '$fBestTime', lead_buyer = '$lbuy'"; $result = mysql_query($query) or die('Failed because: '.mysql_error()); } } // end of for ($c=0; $c < $num; $c++) } } fclose ($handle);
Encoding Error When Importing With Simple XML
When importing XML with SimpleXML -php5-with accents they come with errors... I guest this is an encoding thing... example: when importing this frase in spanish "La Tecnología más avanzada" I get: La TecnologÃÂa más avanzada if the original text was in utf-8 or in iso-8859-1 how do I can get them correctly according to it encoding?
IE+Page Refresh+Resubmitting Data
I am in the processing of developing a site making use of PHP and MySQL. The problem I am experiencing is that when I refresh Internet Explorer, the data that was processed by a form is resubmitted to the database - can anyone tell me what the correct process is to avoid having this happen. The only thing that comes to mind is to, after the processing is complete, redirect to another screen - ultimately I would like to avoid doing that.
Trying To Display 1 Row Of Data On Static Web Page
I have a database with about 600 rows of data, and about 40 fields. I want to display 1 row of data at a time and populate it into a static web page in misc areas on that web page. I am having trouble displaying the results! Do I still need a loop even though I want one record at a time? Code:
Page Reloads Keep Entering Data In Db
The problem is I have a small form that allows a user to input data into a database. Everything works fine, after a successful submission, the user get a message saying that their info was accepted. The problem is that if that page is reloaded, it enters the info again. There is only going to be one person doing the submitting so I could explicitly say...DO NOT RELOAD the page, but that seems kinda half as**d.
Echo RAW Data From Unicode Page?
How can I print raw data (string) from a UTF-8 .php file? Simple echo $var ouputs unicode string to browser (with unicode prefix bytes), but if I want to ouput BLOB data (jpeg file)?
Loading All The Data Of A Page Into A Variable.
I was wondering how you would go about emulating header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename=' . 'test' . '.csv'); but instead of getting a file...I would like to load all the data into a variable. Is this possible?
How To Pass Data To Linked Page ?
when a user clicks on a hyperlink i want to pass data to linked page. but what i want is that this data should not be visible to user. i mean is there any way that i can pass data except get method when user click on hyper link?
How To Combine And Pass Data In One Page?
I didn't know what to use as a title for this. Here is the scenario: I have a op.reqedit.php page. This page a form where you input data. In this page I have split a MySQL field. It is called MachineTypeOfWork and is split into Replace, Adjusted, REbuild, Inspected and Repair. These all become check boxes for the user. The form submits to op.reqadd.php. In this page I first have a hidden box where I combine all of the above into Type (this works fine, I have unhidden the box to see it). Then I have $MachineTypeofWork = $_GET['Type']; $sql_query = mysql_query("UPDATE results SET (a bunch of fields) MachineTypeOfWork='$MachineTypeofWork' WHERE WorkOrder = '$wo'") or die (mysql_error()); My problem is that it updates all of the fields it should except the MachineTypeOfWork field in MySQL. It actually overwrites what is already there with nothing. What I do not know (I am new) is can I combine the field and pass it to the database in the same page or do I need another page in the background for this?
Passing Data To Another Page Using $_SESSION's
Is passing information from one page to another page using $_SESSION okay and secure. Like First name, last name, address, social security number. ... or is there a more secure way of passing the information?
Read Data From External Page?
I have tried to think of a solution to this problem, but i can't find it. My question is: If possible, how do you from your own page confirm that a form has been send from an external page?
INSERT Data On Page Load?
I have an avatar system where certain avatars are locked until the user unlocks them by going to certain pages of the site. So far ( being the newb I am ) I only know how to INSERT data from a form. Is there a way to do it on page load or similar? I also need it to first check if the data already exists and if not it inserts the data and then displays a message to the user that they have unlocked the avatar. Code:
Transport Form Data To Next Page
How can I achieve this: page 1 has a form with textfield1, after clicking submit, page 2 is loaded with another form that also contains textfield1. Can the data that is entered in textfield1 on page 1 automatically be put in textfield1 on page 2?
Passing Form Data Through A Page
I'm in the process of creating a new form that stores customer input into a MySQL database. What i'm attempting to do is allow them to fill out their data, and hit 'next' to go on to a file upload form. Upon completing that form and submitting, all information (including their data from page 1) is posted at the same time (so it's all under the same ID). What would be the easiest way to do this? Right now my submit file (submitquote.php) contains the following data (all on one page). Code:
Importing To DB From Pipe Delimited Text File
I am trying to make a PHP script that will import data from a pipe delimited text file in to a database. The problem I am having is that the fields have long descriptions in them and there are multiple line breaks for paragraphs. They contain HTML codes as well (<B>). The multiple line breaks are causing it to import the data strange, putting data in the wrong fields and totally missing some data as well. Here is what the text file Code:
Transferring Data To Another Page After A Form Process
Quick question: Is it possible to copy some results from a form (via POST) to another page after submitting the form? I'd like to use the results somewhere else later on, but want the form to process normally without the user being forced to redirect to the other page. I've got a vague idea, but I don't know if such a thing would indeed be possible in php or not.
Send Data To Print One Page At A Time
I currently have a script together that will display one record per page and allow the user to manually click through pages to view the next record. How can I translate this to printing the data? I want to be able to print the data one page at a time, but only send one print job to do this? I have never done this before, but would imagine it is possible....
|