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:

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

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by niche1
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:

<?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();
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.