| | |
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: 8
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 |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube






