hello guys i'm new in php programming, currently i'm developing simple student information system, but whenever i try to populate school name and school code, i face this problem
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '61', 'Ng\'walali'), ('62', 'Ng\'walushu'), ('63', 'Ng\'wang\'wita \'A\''), ('' at line 61

here is my insert code

<?php require_once ("mysqli_connect.php"); ?>
<?php
$query = "INSERT INTO school VALUES (
'01', 'Budalabujiga \'A\''),
('02','Budalabujiga \'B\''),
('03', 'Bulolambeshi'),
('04', 'Bumera'),
('05', 'Bunamhala Itilima'),
('06', 'Bunamhala Mbugani'),
('07','Chinamili'),
('08', 'Dasina \'A\''),
('09', 'Dasina \'B\''),
('10', 'Gambasingu \'A\''),
('11', 'Gambasingu \'B\''),
('12', 'Gaswa'),
('13', 'Habiya'),
('14', 'Idoselo'),
('15', 'Ikindilo'),
('16', 'Ikungulipu \'A\''),
('17', 'Ikungulipu \'B\''),
('18', 'Inalo'),
('19', 'Isengwa'),
('20', 'Itubilo'),
('21', 'Kabale'),
('22', 'Kashishi'),
('23', 'Kidula'),
('24', 'Kimali'),
('25', 'Kinang\'weli'),
('26', 'Lagangabilili'),
('27', 'Laini \'A\''),
('28', 'Laini \'B\''),
('29', 'Lalang\'ombe'),
('30', 'Longalombogo'),
('31', 'Luguru'),
('32', 'Lung\'wa'),
('33', 'Madilana'),
('34', 'Mahembe'),
('35', 'Mhunze'),
('36', 'Migato'),
('37', 'Mitobo'),
('38', 'Musoma'),
('39', 'Mwagimagi'),
('40', 'Mwakilangi'),
('41', 'Mwamapalala Mseto'),
('42', 'Mwamigagani'),
('43', 'Mwamtani \'A\''),
('44', 'Mwamtani \'B\''),
('45', 'Mwamunemha'),
('46', 'Mwamungesha'),
('47', 'Mwamunhu'),
('48', 'Mwanhunda'),
('49', 'Mwanunui'),
('50', 'Mwaogama'),
('51', 'Mwaswale'),
('52', 'Nanga \'A\''),
('53', 'Nanga \'B\''),
('54', 'Nangale'),
('55', 'Ndoleleji'),
('56', 'Ngeme'),
('57', 'Ng\'hesha'),
('58', 'Nguno'),
('59', 'Ng\'wabuki'),
('60', 'Ng\'wagindu),
('61', 'Ng\'walali'),
('62', 'Ng\'walushu'),
('63', 'Ng\'wang\'wita \'A\''),
('64', 'Ng\'wang\'wita \'B\''),
('65', 'Nhobora \'A\''),
('66', 'Nhobora \'B\''),
('67', 'Nkololo Itilima'),
('68', 'Nkoma \'A\''),
('69', 'Nkoma \'B\''),
('70', 'Nkuyu'),
('71', 'Ntenga'),
('72', 'Nyamalapa'),
('73', 'Nyantugutu'),
('74', 'Sagata'),
('75', 'Sawida \'A\''),
('76', 'Sawida \'B\''),
('77', 'Senani'),
('78', 'Shishani'),
('79', 'Sunzula \'A\''),
('80', 'Sunzula \'B\''),
('81', 'Zagayu'),
('82', 'Zanzui')";
$result = mysqli_query($dbc, $query)
or die(mysqli_error($dbc));
echo "School added successfully!";
?>

Recommended Answers

All 2 Replies

It happens because you're missing the quote for the previous values, this:

('60', 'Ng\'wagindu),

should be:

('60', 'Ng\'wagindu'),
commented: Good Eye. Was just ablut to say the same thing. +11

Thank you so much cereal, it worked

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.