| | |
Importing into MYSQL Database
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2009
Posts: 13
Reputation:
Solved Threads: 0
I need to import TEST.TXT (located in the same directory as my script
It has 1 Record: "6","Lunch","234"
Iget this error message: Warning: mysqli_close() expects exactly 1 parameter, 0 given in C:\wamp\www\test\import.php on line 19
Why?
Heres my script:
It has 1 Record: "6","Lunch","234"
Iget this error message: Warning: mysqli_close() expects exactly 1 parameter, 0 given in C:\wamp\www\test\import.php on line 19
Why?
Heres my script:
php Syntax (Toggle Plain Text)
<?php // Connect to the MySQL server and select the corporate database $mysqli = new mysqli("localhost","user,"password,"test"); // Open and parse the test.txt file $fh = fopen("test.txt", "r"); while ($line = fgetcsv($fh, 1000, ",")) { $id = $line[0]; $item = $line[1]; $price = $line[2]; // Insert the data into the sales table $query = "INSERT INTO example SET id='$id', item='$item', price='$price'"; $result = $mysqli->query($query); } fclose($fh); mysqli_close(); ?>
Last edited by peter_budo; Oct 22nd, 2009 at 2:18 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
0
#2 Oct 19th, 2009
•
•
•
•
I need to import TEST.TXT (located in the same directory as my script
It has 1 Record: "6","Lunch","234"
Iget this error message: Warning: mysqli_close() expects exactly 1 parameter, 0 given in C:\wamp\www\test\import.php on line 19
Why?
Heres my script:
php Syntax (Toggle Plain Text)
<?php // Connect to the MySQL server and select the corporate database $mysqli = new mysqli("localhost","user,"password,"test"); // Open and parse the test.txt file $fh = fopen("test.txt", "r"); while ($line = fgetcsv($fh, 1000, ",")) { $id = $line[0]; $item = $line[1]; $price = $line[2]; // Insert the data into the sales table $query = "INSERT INTO example SET id='$id', item='$item', price='$price'"; $result = $mysqli->query($query); } fclose($fh); mysqli_close(); ?>
php Syntax (Toggle Plain Text)
$mysqli->close();
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
![]() |
Similar Threads
- How To Connect Remote Mysql Database (Visual Basic 4 / 5 / 6)
- can i use mysql database with asp (ASP)
- Need a good MySQL Database guy (Web Development Job Offers)
- copying mssql database on my local machine to a mysql database online (MySQL)
- Php code confusion. Not sure how to describe (PHP)
- URGENT: UBBThreads MySQL database merge (MySQL)
- Backing up a MySQL database (MySQL)
- Update entire Mysql DataBase with PhP (PHP)
Other Threads in the PHP Forum
- Previous Thread: Executing jar file on server php
- Next Thread: Password change md5 in mysql problem
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code codingproblem cron curl database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory menu methods mlm mod_rewrite multiple mysql oop parameter parse paypal pdf php problem query radio random recursion regex remote script search select send server sessions sms soap source space speed sql static structure syntax system table tutorial up-to-date update upload url validation validator variable video web wordpress xml youtube






