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:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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 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 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:
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?
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 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.
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 PDF Or EPS
Does anyone know of a way to import an existing PDF or EPS for editing without the commercial PDI library?
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 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?
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:
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);
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?
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?
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:
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?
Importing Items From Online Calendar To Mail Client
Has anyone any idea if it's possible to import items from a database table into your mail client calendar? I'm using Ximian Evolution, but Outlook is very relevant to, because most users are still stuck in the M$ mess...
PHP And MySQL: How To Properly Call A Stored Procedure With Output Parameters From PHP - Mysql, Mysqli, Or PDO
I am currently using PHP 5 and MySQL 5, both on Fedora Core 5. I am unable to call a MySQL stored procedure that returns output parameters using mysql, mysqli, or PDO. I'm having a hell of a time with it... The following comes from phpinfo(): PHP Version: 5.1.2 mysql Client API version: 5.0.18 mysqli Client API version: 5.0.18 PDO Driver for MySQL, client library version: 5.0.18 MySQL version, from running SELECT version(); = 5.0.18 Here's the procedure I've created in MySQL: CREATE PROCEDURE testproc(OUT p_testvar varchar(50)) BEGIN SET p_testvar = 'HELLO WORLD!' END [color=blue] >From the MySQL Command Line, I can do the following:[/color] mysql> call testproc(@a); Query OK, 0 rows affected (0.00 sec) mysql> select @a; +--------------+ | @a | +--------------+ | HELLO WORLD! | +--------------+ 1 row in set (0.00 sec)
MySQL Error - Supplied Argument Is Not A Valid MySQL-Link Resource
I am getting the error Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/server7/public_html/71/arranholloway/database4.php on line 7 I tested my code on local computer and there were no problems, the error message only appeared when I loaded it onto my web hosters server. I'm new to PHP so its probably something simple but any help would be appreciated.
Connection With MySQL. Navicat - CANNOT CONNECT TO MYSQL SERVER ON LOCALHOST
I am new in PHP & MYSQL. I installed PHP & MYSQL properly. To easy operate for MYSQL I installed Navicat and it installed properly. But when I am going to test the connection between MYSQL & Navicate the error message showing CANNOT CONNECT TO MYSQL SERVER ON LOCALHOST (10022) it should mention that my connection name = localhost, Ip = localhost,port = 3306 , user name = root in Navicat.
PHP Saying Error In Mysql Syntax, But Written My Mysql Query Browser!
I have a basic db that I access with MySQL query browser. Everything seems fine to me but I am using this db as part of a php shopping basket and when I try to add an item I get: Notice: Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '>function.extract]: First argument should be an array in functions.inc.php on line 31 Notice: Undefined variable: price in functions.inc.php on line 36 Notice: Undefined variable: price in functions.inc.php on line 39 Notice: Undefined variable: total in unctions.inc.php on line 39 I'm assuming the last three are caused by this problem as price should be passed to the cart, and total is worked out using it. However although I know mySQL code it was the MySQL query browser that actually generated the code and I cannot see a way to view or debug the code. The db has one table in it which is made up of id, name, subname, desc, and price. The code in the php file that is being referred to is:
Automatic Scheduled MySQL Backup (MySQL Dump)
Is it possible to configure a UNIX/LINUX server to do a MySQL Dump for a database on an automatic schedule and then to email the dump file to me (the administrator)? I want to be able to have my database automatically backed up every week and emailed to me for storage purposes without any action on my part.
PHP/MySQL: Using PHP To Probe MySQL Db And Send An Email Automatically
Let's say you have a login feature on your site... and a user forgets their password which is stored along side their email address in a MySQL database. Is it possible to use PHP to automatically send the password to that email address upon request? If so, please provide a detailed solution. If not, can Java be used in some way to accomplish this?
--with-mysql ? Php-4.4.2 With Mysql Install In Special Directory
I'm trying to link php-4.4.2 with mysql install in special directory, like /usr/newsystem/mysql, but whatever options I try, php always gets linked to version in /usr/local/lib. I've tried several options: --with-mysql=/usr/newsystem/mysql --with-mysql-dir=/usr/newsystem/mysql --with-mysql-lib=/usr/newsystem/mysql --with-mysql-lib-dir=/usr/newsystem/mysql ....but none of them work, CLI is always build against /usr/local/lib/ libraries.
Create A Sequence In MySQL, With Mysql Variable?
This might be fairly easy to do and I think I've seen the code before, but I haven't seen many good examples of this. Of course Pear::DB probably uses this code in some of its API, probably in dealing with auto-increment indexes and prepared statements. Maybe I'm off base here, but I'm looking for something like this: (psuedo-code) Of course the seq table only needs 1 row holding id, which is updated. select id from tbl; // get result resouce and do fetch, store value in $myid set @myvar = $myid + 1; // can php send to MySQL with a query? ( never seen this ) update myseq set id=@myvar // send this statement through in a update/query // for use in PHP code $newSeqVal = $myid +1
Create A Sequence In MySQL, With Mysql Variable?
This might be fairly easy to do and I think I've seen the code before, but I haven't seen many good examples of this. Of course Pear::DB probably uses this code in some of its API, probably in dealing with auto-increment indexes and prepared statements. Maybe I'm off base here, but I'm looking for something like this: (psuedo-code) Of course the seq table only needs 1 row holding id, which is updated. select id from tbl; // get result resouce and do fetch, store value in $myid set @myvar = $myid + 1; // can php send to MySQL with a query? ( never seen this ) update myseq set id=@myvar // send this statement through in a update/query // for use in PHP code $newSeqVal = $myid +1
Copy And Paste On MySQL To MySQL Database
Would there be any issues if i literary Copy and Paste a mysql db from one server to another mysql db server? When i say "copy and paste" is just like tranferring one word doc from one pc to another pc. I tried the copy and paste already and the new server had recognize the DB i had pasted. I just want to confirm if there would be issues doing it so.. Or should i use Mysql.com Migration toolkit?
Php/Mysql- Uploading Mysql Database
I've set up a basic database using Mysql (just creating a web blog I followed a tutorial) and then started writing the php code for interacting with the database. how do I put the Mysql database onto the the web server where I have server space (the server I use is just some company that I pay €100 a year for). I need the php file to get the data from the Mysql database...
Problem Getting PHP To Recognize MySQL, Using PHP 4.3.7 And MySQL 4.0.20
I have both PHP 4.0( RPM) installed and MySQL 4.0.20 installed with the mysqld daemon up and running. But when I look at the output of phpinfo() , I do not see it there, which is worrisome and so I tried to recompile PHP and do ./configure with the --with-mysql=path but I don't really know where my mysql's header files should be , is there any way to find that out by using any of the mysql commands? I did try to do ./configure for PHP4 without any parameters and when I looked at the output, I do see that PHP seems to recognize that mySQL is there : .... checking for MSSQL support via FreeTDS... no checking for MySQL support... yes checking for specified location of the MySQL UNIX socket... no checking for MySQL UNIX socket location... /var/lib/mysql/mysql.sock checking for inline... (cached) inline ..... Hence, why is that when I do phpinfo() , mySQL still doesn't show up? I suspect that mysql isn't working correctly with php, because if I use the mysql_connect() function in my php, I get the error "Fatal error: Call to undefined function: mysql_connect() " and yet it DOES seem like PHP recognizes mysql is there. That "unable to recognize mysql_connect function" error comes up after installing PHP using ./configure with or without any parameters.
Seeking Resources On Mysql, Not Mysql.com
I'm looking for some resources that can aid me in getting deeper into php/mysql. I am presently looking at a syntax that lets me check a mysql row for one particular value, using sql. Then I look for a sql based solution to get a column name based on the above value. Last I need to update that row, actually NULL that particular field in that particular row. I've been reading mysql.com the function list all afternoon, nothing found that might make it able for me to write those statements in question. So now I better expand and seek new sources, google.com didn't give me much while searching the groups.
Migrate Old Mysql DB To New Mysql Server
I am trying to migrate our old mysql DB to another new mysql server using AB: MySQL Migration Tool. The migration has some problem. One of the tables from the old DB had a column defined Datatype as DATE. However, when I do migration. The migration informs me that " The following error occured while transfering data from log Cannot convert value '0000-00-00' from column 13 to TIMESTAMP." I believe the migration forces to convert the datatype into timestamp. The work around i can do on this is to change the datatype of the column on the old DB into Timestamp. However, I don't want that. I want to retain the DATE datatype.
MySQL? XML? XML And MySQL? SQLite?!
I've been using PHP for a while now and I'm beginning to migrate to PHP5. So far, I'm impressed. I need to develop an admin application to enable users to update a website that is built on a MySQL database. In most cases, I'd simply develop an application to manipulate the database but as the website is updated fairly infrequently, I am considering a number of further options instead to alleviate server load. I am considering retaining the MySQL database for structure and building scripts to generate XML from the data that can be processed and transformed server-side (XSLT). Another option is SQLite. And yet another approach is to generate static HTML pages from the database when it needs to be updated or published.
MYSQL To WEB
What I want is for people to be able to come to a page put in an id number and all their information pop up on the screen, then maybe even have then be able to edit it, can anyone help or tell me where to look.
PHP/MySQL
I've got a petition database running from MySQL and i want to display the entries or "signatures" on a page with a limit of 100 signatures per page, creating links at the bottom of each page. Say i had 243 signatures, I want the links at the bottom to look like this: "1-100, 101-200, 201-243" rather than: "1-100, 101-200, 201-300" (Which is what i had working before) I've done this code, but it's not working. Here is the code:
PHP, MySQL On IIS
I am running IIS, and i have php installed (and is working). I have installed MySQL onto the same pc, and i am running mysqladmin. If i want to run mysql commands in php should they work like this, or do i need to set up an odbc connection to the mysql server or something? I am asking because currently what is happening is that i have IIS running along with MySQLadmin, and when i try to connect to the database it says it can't.
New To PHP And MySQL
I'm am just beginning to learn PHP and MySQL. My web host does not allow telnet access, so I am trying to find a php script or something that will let me edit my database through my browser. Does anyone know of anything?
POS With MySql And PHP
I am thinking to create an app POS using mysql,php and apache with web interface for a company that it wants reduce costs about dedicated lines for using internet. My question is : 1-)Can I use the mask for function keys and how? 2-)How can I print using a button or a link to send directly to printer or using Print Manager for Windows? 3-)If I open a new window how can I close this using PHP?
MySQL
is there anyways to *downlaod* a whole MySQL DB, and export it into MS Acces / Excel ?
|