In the table, the fields where variables are inserted are empty.

Here is the code:

<?php $handle = @fopen("1.txt", "r"); $buffer = array(); if ($handle) { while (($buffer[] = fgets($handle, 4096)) !== false) { // echo $buffer.'<br>'; } if (!feof($handle)) { echo "Ошибка: fgets() неожиданно потерпел неудачу\n"; } fclose($handle); } $x=0; foreach ($buffer as $value) { $adress = $buffer[$x]; echo $adress; $x++; $name = $buffer[$x]; // echo $name; $x++; $lat = $buffer[$x]; // echo $lat; $x++; $lng = $buffer[$x]; $x++; $photo = $buffer[$x]; $x++; $type = $buffer[$x]; $x++; } $connect=mysql_pconnect ("localhost","root",""); if ( !$connect ) die ("Невозможно подключение к MySQL"); $db="map"; mysql_select_db ( $db ) or die ("Невозможно открыть $db"); $strSQL = "SELECT * FROM `markers` ORDER BY `markers`.`id` ASC "; $rs = mysql_query($strSQL); $result = mysql_query("INSERT INTO `markers` (marker, name, address, lat, lng, photo, type ) VALUES ('batarei', 'Батарейки', '$adress' , '$lat', '$lng', '$photo', '$type')"); if ($result) { echo ("Добавление прошло успешно 1"); } else { echo ("Данные не были добавлены 2"); } echo mysql_error(); mysql_close($connect); ?> 
  • Start better with what you have in the file and in what form and how much it is. - teran
  • I think it will help you: ru.stackoverflow.com/questions/53127/… - PavelNewSky
  • 16kb file inside line by line: vul. Danilevskogo, 32B Batteries 50.00907365246954 36.22150275767217 images / nophoto.png Company / organization: “Two Comrades”. Contact date: tel. 700 03 09. Mail people, just finished the point: brinko.vitaliy@mail.ru. Коментар: The acceptance of batteries takes place from 9.00 to 18.00 vul. Donets-Zakharzhevsky, 6/8 Batteries 49.9941233 36.2339813 images / nophoto.png Store “Mandrіnnikіv Club”. tel. 755-80-53 - 13zone
  • one
    @ 13zone is unlikely to give us something that is stored inside the file. look at the data recorded in variables, sort out the quotes and see what the server is responding to, maybe it doesn’t find any column, for example ... - PavelNewSky
  • one
    And why you insert is not in a loop? you now in turn read all the lines into variables, and then, when you have left in the variables, the last line data is inserted. And it is better to go to MySQLi / PDO and use prepared queries and variable binding php.net/manual/ru/mysqli-stmt.bind-param.php Otherwise, quotes inside the data will break everything for you. - Mike

0