XAMPP MYSQL PHPMYADMIN database import Error #1064 - php

Having a heck of a time getting a site running locally.
Working with XAMPP for open source preferences over WAMP (no one is sure what WAMPS GPML license is apparently).
I've tried compatibility modes : None : Oracle : Traditional : MYSQL40
I've tried encoding : utf8 : utf16
Apache and SQL run perfectly but when using PHPMyAdmin to import the website database I continually get errors regarding syntax errors in the table data itself.
I attribute this to XAMPPs default incorporation of MariaDB in the latest release I'm using. I can import this database dump easily on another host's virtual SQL 5.5 server. I can also upload this database into WAMP without errors.
Looking this row over it doesn't stand out from any other rows empty fields or data fields.
MySQL: Error
MySQL said: Documentation
#1064 - 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
Field1, Field2, Field3, etc,... atline 123
Interestingly the first table is created and stops short. The sequence of rows are consistent until 241 jumps to 245, then 272, and then crashes with error above on row 447?
MySql Error logs are also changing based on encoding options. Not sure if I'm digging myself into a hole while I resolve the unknown.
Most of the Event Viewer MySql Error Logs show:
Missing system table mysql.roles_mapping; please run mysql_upgrade to create it
Just upgrade MySql, what type of an update is that? What about upgrading MariaDB?
And a few of these:
Incorrect definition of table mysql.proc: expected column 'sql_mode' at position 14 to have type set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVA
Playing with export options I get this error from the first Create Table Statement:
CREATE TABLE IF NOT EXISTS "Table1" (
"PRIMARY" int(123) NOT NULL AUTO_INCREMENT,
"COLUMN1" varchar(123) NOT NULL DEFAULT 'A',
"COLUMN2" int(123) NOT NULL DEFAULT '0',
"COLUMN3" varchar(123) DEFAULT NULL,
ETC...
MySQL said: Documentation
#1064 - 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 '"TABLE" (
"ID" int(123) NOT NULL AUTO_INCREMENT,
"COLUMN1" varchar(123) N' at line 1
Currently picking through the data dump on Notepad++
Thank you in advance!

Not doube-quotes (") around column names, backtics (`).
Nothing you mentioned indicates a need to change the CHARACTER SET (encoding).
One of your errors points to sql_mode; let's see it in context.

Related

INSERT by ANSI_QUOTES mode

I'm having a problem trying to do an INSERT, it's succeeding even though it shouldn't.
My table structure:
Note: given1, given2 and given3 are required fields.
In my application I execute the following method (https://github.com/catfan/Medoo):
$this->medoo->insert('teste', ['dado2' => 11, 'dado3' => 'teste']);
This should not be accepted because data2 is of type SET, and data3 is of type INTEGER`. Even so, the insertion succeeds. Moreover, data1 is not passed as an argument, even though it is a required field.
I checked the MySQL log and got the following entries:
SET SQL_MODE=ANSI_QUOTES;
INSERT INTO "teste" ("dado2", "dado3") VALUES ('11', 'teste');
Running this SQL manually in the database, I discovered that the problem is in using ANSI_QUOTES. The database somehow accepts the insert, and instead of issuing an error message it issues a warning:
I think that is need to modify the Medoo source code or report this problem to MySQL. I do not know what to do.
MySQL version is 5.7.14
I use the MySQL Workbench 6.3.6
When mySQL server is set in STRICT mode, it produces error when you try to insert values that do not fit into a column. By calling SET SQL_MODE=ANSI_QUOTES; this strict mode is most likely disabled.
You can try to contact the author of Medoo framework or rather use another framework or just PDO to access your database.
See mysql docs on server modes for more information.

MSSQL PHP driver returns DateTime string as NULL

When doing an INSERT via PHP into a MSSQL DB, I get the following error:
mssql_query(): message: Cannot insert the value NULL into column
'wmu_startdate', table 'wmuPortal.dbo.tbl_projects'; column does not
allow nulls. INSERT fails. (severity 16)
But the SQL string is
INSERT INTO tbl_projects
(startdate)
VALUES
(
(SELECT CAST('31-08-2016' as datetime))
)
The Query executes fine when run in Microsoft SQL Server Management Studio. Via the PHP Extension, the error above occurs. I already toggled mssql.datetimeconvert = Off #/On in php.ini.
The same error occurs without the SELECT CAST statement, ie. only a String as the value. The startdate column is of type datetime.
UPDATE
I now have a working query. But this still doesn't solve whatever causes the incorrect handling of dates by default...
Replacing the SELECT CAST Statement with
(SELECT CONVERT(DATETIME, '31-08-2016', 105))
Does the trick. Now: What setting do I have to alter in order to get the mssql/freetds extension to handle this automatically?
A known-good test server does not specify anything in /etc/freetds/locales.conf or other places. mssql.datetimeconvert = Off is set on both servers.
I also set other time/date related options in php.ini (copied from known-good server), without success. Is datetime handling affected by other system/environment variables?

mutiple insert Query Works in phpmyadmin but does not work in php script

I have a project on godaddy shared hosting. I am able to run the following query in phpmyadmin successfully: (this is the exact output of the php script)
INSERT INTO payments_facebook(`adset`,`amount`,`date`,`oid` ) VALUES ('6023516764849','3.27','2015-07-25','58');
INSERT INTO payments_facebook(`adset`,`amount`,`date`,`oid` ) VALUES ('6023315002249','200','2015-07-25','53');
INSERT INTO payments_facebook(`adset`,`amount`,`date`,`oid` ) VALUES ('6023221698649','3.43','2015-07-25','52')
I am using the old mysql_query function to insert the data. When I run this query through PHP I get a following error message:
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 payments_facebook(`adset`,`amount`,`date`,`oid` ) VALUES ('602331500' at line 1
but when I run the same query in phpmyadmin it works perfectly.
Here is the structure of the mysql table:
id int(100):
date varchar(30) latin1_swedish_ci
oid int(50)
amount double
adset varchar(200) latin1_swedish_ci
Hopefully someone can help me figure this out, I am not sure if this is a godaddy server limitation or if I have an error in my DB or syntax.
Thank you in advance.
Try this :
$sql = "INSERT INTO payments_facebook(`adset`,`amount`,`date`,`oid` ) VALUES
('6023516764849','3.27','2015-07-25','58'),
('6023315002249','200','2015-07-25','53'),
('6023221698649','3.43','2015-07-25','52')";

MySQL statement becomes corrupt during query excution

I'm making Wordpress custom page with php. When I execute query, it gives error below:
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 '��brand VARCHAR(70),serialCode VARCHAR(70),QRCodeAddress VARCHAR(70),email VAR' at line 1
As you can see, you can see strange char � that usually happens from encoding problem. But what I wonder is that if I echo my sql statement, it has no any problem. Look bellow:
CREATE TABLE SerialTable(id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,brand
VARCHAR(70),serialCode VARCHAR(70),QRCodeAddress VARCHAR(70),email VARCHAR
(70),sex VARCHAR(70),age VARCHAR(70),purchasePath VARCHAR(70),expiryDate
VARCHAR(70),registeredDate VARCHAR(70),modelName VARCHAR(70),colorCode VARCHAR
(70))
And it even works well if I excute in MySql shell.
My procedure is like this:
I'm reading UTF-8 csv file to read table column information
Depending on csv file information, make SQL statement like above and save it in variable $sqlStr
when i echo $sqlStr, it has no any syntax error and even works in MySql shell.
But when $wpdb->query($sqlStr), it give error like above.
I tried to use mysqli_query($conn, $sqlStr) as well. and it give same error.
MySql server info:
Of course connection is localhost as long as web server and mysql server is on same computer.
MySql server collation : utf8_general_ci
mysql server charset : latin_swedish_ci
I've been trying to solve this problem for more than 48 hours and am completely stuck?
It is very likely that your CSV file contains "unprintable" characters that allow it to look normal within an editor.
Try deleting the offending line or lines and recreate them.

How to trace/fix an SQL syntax error?

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`);

Categories