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
// 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();
?>

Recommended Answers

All 2 Replies

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
// 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();
?>
$mysqli->close();

Wow!

Thank You very much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.