I have a problem when I try to insert something in my MySQL database.
Here is the error:
Query error: 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 'LIMIT 1' at line 1 - Invalid query: INSERT INTO banlog (ID, ip, player, admin, reason, day, time) VALUES (NULL, 'Offline','4Gamers','4Gamers','3/3 warns', '3' , '2019-10-13 23:42:09') LIMIT 1
Here is the code:
$query = $this->db->query("INSERT INTO `banlog` (`ID`, `ip`, `player`, `admin`, `reason`, `day`, `time`) VALUES (NULL, 'Offline',?,?,'3/3 warns', '3' , '$time') LIMIT 1", array($info['name'], getUserData($this->session->userdata('logged_in')["id"], "name")));
Thanks.
Try removing LIMIT 1.
I hope this will solve your problem.
Related
Try to use this query
insert into `popups` (`GroupID`, `Name`,`ShortName`) VALUES
(SELECT `GroupID`,`Name`,`ShortName` FROM `temp` WHERE `GroupID` = '1')
#1064 - You have an error in your SQL syntax;
Tables popups and temp almost identical - hase same columns.
What is wrong in request?
It's either insert...values or insert...select in your case drop values
insert into `popups` (`GroupID`, `Name`,`ShortName`)
SELECT `GroupID`,`Name`,`ShortName` FROM `temp` WHERE `GroupID` = '1'
https://dev.mysql.com/doc/refman/8.0/en/insert.html
I've got a question about SQL (php), I want to INSERT data in my table. But I want to use the IF NOT EXIST value.
What I've tried:
INSERT INTO vrienden (id, userid, vriendmetid, accepted) VALUES (null, '1', '20', '0') WHERE NOT EXISTS (SELECT * FROM vrienden WHERE userid='1' AND vriendmetid='20')
I'm not sure what's wrong, because I get the following error:
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 'WHERE NOT EXISTS (SELECT * FROM vrienden WHERE userid='1' AND vriendmetid='20')' at line 1
Thanks.
You want insert . . . select, not insert . . . values:
INSERT INTO vrienden (id, userid, vriendmetid, accepted)
SELECT x.*
FROM (select null as id, '1' as userid, '20' as vriendmetid, '0' as accepted) x
WHERE NOT EXISTS (SELECT 1 FROM vrienden v WHERE v.userid = x.userid AND v.vriendmetid = x.vriendmetid);
However, you probably shouldn't be doing this in the INSERT. Instead, create a unique index/constraint:
create unique index unq_vrienden_userid_vriendmetid on vrienden(userid, vriendmetid);
This way, the database will ensure uniqueness of the columns, so your application does not have to.
I've got a little problem with a sql request:
my $sql resquest ( result of echo $sql ):
INSERT INTO match (id, id_match, login, real_login, reponse, date) VALUES (NULL, '11', 'CaptainRida', 'rbikitar', 'oui', '2014-06-07')
and the error
Error: 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 'match (id, id_match, login, real_login, reponse, date) VALUES
(NULL, '11', 'Capt' at line 1
the sql request is truncated at 'login'. always 4 characters and BAM truncated.
can anyone help me, I have THE SAME SQL RESQUEST with another table ( exactly the same except rencontre instead of match and id_rencontre instead of id_match)
the "rencontre" request works great and the "match" request is truncated in the error.
MATCH is a MySQL reserved word.
Enclose it in backticks:
insert into `match` (id, id_match, ...
Or, consider changing the name of the table to not use a reserved word (recommended).
This question already has an answer here:
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Closed 8 years ago.
MySQL keeps reporting an error when executing the SQL query. Everything looks right to me, but Ive been looking at it for about an hour now.
"INSERT INTO invoices
(total, generated, account, market, status, name, hash)
VALUES
('$total', Now(), '$aid', '$mid', '$name', 'Active', '$hash')"
Error
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 'desc, account, market, status, name, hash) VALUES ('499.99', NOW(), 'System gene' at line 1 (SQL: INSERT INTO invoices (total, generated, desc, account, market, status, name, hash) VALUES ('499.99', NOW(), 'System generated invoice during Market setup/activation.', '6', '9', 'Zac Company - Chandler', 'Active', 'b0521f6668cb87de009866b67b25b458')
I think this is an easy fix that just needs fresh eyes.
There it is
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 'desc, account,
desc is a reserve word and so must be escaped with back quote
`desc`
Also, total is a numeric column; so no need of quoting it
Your sql query should be like below
INSERT INTO invoices (total, generated, `desc`, account, market, status, name, hash)
<--Here
VALUES (499.99, NOW(), 'System generated invoice during Market setup/activation.',
'6', '9', 'Active', 'Zac Company - Chandler', 'b0521f6668cb87de009866b67b25b458')
I'm trying to run the following statement:
INSERT INTO table (
as,
ad
,af,
ag,
ah,
aj
)
VALUES (
'a',
'b',
'c',
'd',
'e',
'f'
)
ON DUPLICATE KEY UPDATE (
aj='dv',
ah='ev',
ag='fv'
);
and getting the following error:
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 '(ag='dv',ah='ev',ah='fv')'
at line 3
Any advice?
thx
Skip the ()..
INSERT INTO site_domains_meta
(domainname,metatype,pagename,english,indonesian,japanese)
VALUES ('a','b','c','d','e','f')
ON DUPLICATE KEY UPDATE english='dv',indonesian='ev',japanese='fv';
http://dev.mysql.com/doc/refman/5.5/en/insert.html