0
INSERT INTO devices3 (`name`, `ip`, `port`, `switch`) VALUES (name, 255.255.255.255, 55555, 12);

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.255.255, 55555, 12)' at line 1.

+--------+-------------+------+-----+---------+----------------+
| Field  | Type        | Null | Key | Default | Extra          |
+--------+-------------+------+-----+---------+----------------+
| id     | int(11)     | NO   | PRI | NULL    | auto_increment |
| name   | char(25)    | YES  |     | NULL    |                |
| ip     | varchar(15) | YES  |     | NULL    |                |
| port   | int(5)      | YES  |     | NULL    |                |
| switch | int(4)      | YES  |     | NULL    |                |
+--------+-------------+------+-----+---------+----------------+

why is this not working?

Dharman
  • 30,962
  • 25
  • 85
  • 135
Kai H.
  • 39
  • 1
  • 5
  • Why are you not quoting the IP? It's of type `varchar`. – chb Feb 25 '18 at 06:06
  • Does this answer your question? [When to use single quotes, double quotes, and backticks in MySQL](https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql) – Dharman Oct 05 '21 at 21:18

2 Answers2

0

I see the problem is ip address as it is a string. You have to have quotation marks around like below:

INSERT INTO devices3 (`name`, `ip`, `port`, `switch`) VALUES (name, '255.255.255.255', 55555, 12);
slon
  • 1,002
  • 1
  • 8
  • 12
0

varchar must be enclosed into quotes, '255.255.255.255'

Nikolai Shevchenko
  • 7,083
  • 8
  • 33
  • 42