Reputation: 289
I am receiving an error
error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'all (Abonent, Opponent, Type, Data, Duration, idBase, IMEI, Direction) value' at line 1
while trying to run this code:
$sql = "SELECT * from table";
$res = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_row($res)){
if ($row[2]=='Передача данных'){$type = 'Интернет';}else {$type = NULL;}
$date = date_create_from_format ( 'd.m.Y H:i:s', $row[3]);
$da= date_format($date, 'Y-m-d H:i:s');
$mysql = "INSERT INTO all (Abonent, Opponent, Type, Data, Duration, idBase, IMEI, Direction)
values ('$row[0]', '$row[1]','$type', '$da', '$row[4]', '$row[5]', '$row[6]', '$row[7]')";
$result = mysqli_query($conn, $mysql);
}
I've checked similar questions here: none of the attribute names are seem to be keywords, neither is in the use of backticks. Types of my table attributes:
Abonent bigint(12) (key)
Opponent bigint(12)
Type text
Data datetime
Duration bigint(20)
idBase bigint(10) (key)
IMEI bigint(16)
Direction varchar(15)
Upvotes: 0
Views: 73