INSERT INTO `jos_core_acl_aro`
VALUES (NULL, 'users', LAST_INSERT_ID(), 0, 'Administrator2', 0);
INSERT INTO `jos_core_acl_groups_aro_map`
VALUES (25, '', LAST_INSERT_ID());
I get this 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 'INSERT INTO jos_core_acl_groups_aro_map VALUES (25, '', LAST_INSERT_ID())' at line 3*
I am recovering my joomla password. I added user but I can't set his permissions.
Quite likely, the reason is, that you execute two queries separated by ;.
Run both queries one and another separately, shouldn't show up the error.
As others asked, by means of which system do you submit the queries to the database?
Related
$sql = "INSERT INTO couponentries (itemid, coupon, MSISDN, channel, result)
VALUES ('".$itemid."','".$CouponCode."', '".$MSISDN."','".$channel."','".$status."')
ON DUPLICATE KEY UPDATE couponentries.result = VALUES('Invalid couponcode[ERR: Already exists]')";
I am trying to insert new item from PHP webform to MySQL database. If I insert a duplicate row I will make the result update to an error message. Here is my code. It keeps giving me a syntax error.
ERROR: Could not able to execute 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 ''Invalid couponcode[ERR: Already exists]')' at line 3
You are using a string literal to update your column - lose the values:
$sql = "INSERT INTO couponentries (itemid, coupon, MSISDN, channel, result)
VALUES ('".$itemid."','".$CouponCode."', '".$MSISDN."','".$channel."','".$status."')
ON DUPLICATE KEY UPDATE couponentries.result = 'Invalid couponcode[ERR: Already exists]'";
Obligatory side note:
Concatinating strings like this makes your code is vulnerable to SQL Injection attacks. You should probably look into Prepared Statements instead.
I need to insert a POINT value into my MySQL table using Fat Free Framework. I was hoping to do this using the F3 Mapper, but I got the impression that is not possible.
So I tried to use $db-exec()
This is my current code, based on various searches here and on google.
$geopoint = "POINT($lat $long)";
$db->exec("INSERT INTO event_dates ('eventGeoPoint') VALUES ($geopoint)");
This throws an error:
PDOStatement: 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 '52.8583742))' at line 1
I have also tried
$db->exec("INSERT INTO event_dates ('eventGeoPoint') VALUES (GeomFromText($geopoint))");
Please tell me how to correctly insert a POINT() value into my database using Fat Free Framework, either the mapper or exec
You need to correct your INSERT statement, which you are mixed with UPDATE statement.
INSERT INTO mytable SET myGeoPoint = 'GeomFromText($geopoint)
should be
INSERT INTO mytable(myGeoPoint) values (GeomFromText($geopoint))
Also, you need to use Prepared Statement to avoid SQL Injection.
Searching on after #Ravi's comments I found the answer in this post.
I changed my statement to
$result= $db->exec("INSERT INTO mytable (GeoPoint) VALUES (PointFromText(CONCAT('POINT(',$lat,' ',$long,')')))");
And it works!
I'm attempting to make use of the OUTPUT line so I don't have to use multiple queries to get information that I've inserted into a table. This is for a basic image uploader project that will rename the images based on their id in the database.
Here's the query I'm using (Using it with PDO)
INSERT INTO `images` (`id`, `type`, `category`, `title`) VALUES (null, :type, :cat, 'Newly uploaded image') OUTPUT INSERTED.id;
-
Processing upload
Error uploading file: SQLSTATE[42000]: Syntax error or access violation: 1064 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 'OUTPUT INSERTED.id' at line 1
I've read over a few different tutorials now and I'm really confused as to what the problem is.
OUTPUT is not working in MYSQL.
Use
SELECT LAST_INSERT_ID();
after your insert query
I'm trying to import a huge database file to my local dev environment to fix some errors I'm getting on the Magento back-end. I fixed the issue where it wouldn't import based on size, time, and memory. Now I've uncovered this gem of an error which says that my SQL syntax is wrong.
Not sure how that's possible because this is the exact file we're using in production but still, it's driving me nuts. Any help is appreciated.
SQL query:
DELIMITER ; ;
MySQL said: Documentation
#1064 - 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 'CREATE*/ /!50017 DEFINER=root#localhost/ /*!50003 TRIGGER
trg_catalog_prod' at line 1
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`#`localhost`*/ /*!50003 TRIGGER trg_catalog_product_website_after_insert
AFTER INSERT
ON catalog_product_website FOR EACH ROW
BEGIN
INSERT IGNORE INTO `cataloginventory_stock_status_cl` (`product_id`) VALUES (NEW.`product_id`);
INSERT IGNORE INTO `catalogsearch_fulltext_cl` (`product_id`) VALUES (NEW.`product_id`);
INSERT IGNORE INTO `catalog_product_index_price_cl` (`entity_id`) VALUES (NEW.`product_id`);
trying to add data to mySQL db.
I get this 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(time, date, location, weather, team_id) VALUES('t', 't', 't','t','2')'
this is the PHP code snippet:
$sql = "insert into MATCH(time, date, location, weather, team_id) VALUES('$time', '$date', '$location','$weather','$team_id')";
I cant see any syntax errors
MATCH is a reserved for a function used in fulltext search:
http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html
That's not a php syntax error. It's a Mysql syntax error. I suggest changing the table's name.
Try
$sql = "INSERT INTO `MATCH` (`time`, `date`, `location`, `weather`, `team_id`) VALUES ('".$time."', '".$date."', '".$location."','".$weather."','".$team_id."')";
Using the backtick character ` you can distinguish names you gave to your table or columns from reserved words of the MySQL language. Leaving them out might seem more compfortable at first, but can be a pain later.
E.g. one should know that mysql syntax is not case sensitive. So even if you write match you will get this problem. A list of the reserved words can be found at the link Mark gave you in his comment.
You might also want to read up on MySQL Syntax in general:
http://dev.mysql.com/doc/refman/5.1/en/sql-syntax.html