Whenever I am inserting any blank data in my table it works on XAMPP but it does not work on my IIS server having PHP version 5.3 and MySQL version 5.5 I found error. What setting should I do in my configuration file so that any null value and blank data can be inserted, not only that if my table has five columns and if in one query page only two data is to be inserted rest is not written then also it shows error which is
insert failed Field 'XXX' doesn't have a default value
insert failed Data truncated for column 'Man_Days' at row 1
Is there any setting changes which can be done in my.ini or php.ini or config.inc.php
Firstly You must try to avoid inserting blank data in table. if it's not possible then try to insert the field which have value. So You may try to use Your mysql insert query like below:-
insert into table_name (field1,field3) values(value1,value2);
Related
I'm trying to import data from sql files into local MySQL database. I'm using WampServer2.5, MySQL 5.6.17. I'm importing them using MySQL console as PHPMyAdmin interface was causing some problems.
First two files seem to be uploaded correctly. However, they were much smaller than the third one. The steps are always the same:
1. create database xyz;
2. use database xyz;
3. SET FOREIGN_KEY_CHECKS = 0;
4. source path/to/the/xyz.sql
When uploading the third file at some point I get this errors (a couple in a row, then it keeps uploading):
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: [some number]
Current database: xyz
Then a get a few of those, which is strange as I set that in the beginning (maybe there is some reset of this setting when connection is lost?):
ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
The result is I have all the tables uploaded, but some of them have no data - mostly because they are referencing user table from that third database, which has no records.
Ideas / questions:
I tried to edit php.ini file to increase memory limit, max file upload size but there is no effect on PHPMyAdmin interface
Can I find only one table in sql file and upload the records to the table in my MYSQL database?
The table was updated after I opened the full sql file i Notepad++, found only lines with inserted values into that particular table, saved it as a new sql file and used 'source' command then.
I am having serious headache with MySQL database. Here is my problem.
I am developing a website in Php with SQL Server as database, everything working fine. database 1
Than I have to change database to MySQL, I've done that and create some stored procedures and function, everything working fine here too. database 2
Now I've have to shift MySQL database to another MySQL server, database 3. Problem occurs here because now my old stored procedure and query which I've created are not working. My DB3 structure is same as DB2.
If I fire this query in DB2 select * from Online_Patient; no error.
Same query in DB3 throws an error:
Error Code: 1146. Table 'Online_Patient' doesn't exist
But when I change my query to select * from online_patient; it gives me correct result.
So is there any way to solve this error or do I have to change all query and stored procedures, there are dynamic query in stored procedure so just can't convert upper case to lower case.
Locate your mysql configuration file. It should be named my.cnf. You can run mysqld --help --verbose in the beginning of the output the are the default locations where you can look for the file. My output is:
Default options are read from the following files in the given order:
C:\Windows\my.ini C:\Windows\my.cnf C:\my.ini C:\my.cnf C:\xampp\mysql\my.ini C:\xampp\mysql\my.cnf
Find the lower_case_table_names directive and set it to 1:
lower_case_table_names = 1
From MySQL documentation: http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_lower_case_table_names
If set to 0, table names are stored as specified and comparisons are case sensitive. If set to 1, table names are stored in lowercase on disk and comparisons are not case sensitive. If set to 2, table names are stored as given but compared in lowercase. This option also applies to database names and table aliases. For additional information, see Section 10.2.2, “Identifier Case Sensitivity”.
Then restart mysql server.
I have an is_active column in my database. How do I set the value of an enum data-field to be (0,1) in XAMPP. I tried the value field but that doesn't work.
Xampp uses MySQL as a backend, so you should look at the database documentation if you get lost. That being said, the problem is that an enum data type can only be set to particular values, most likely 'active' and 'inactive'. You can load up phpmyadmin to see the details of the database configuration, or connect through the command line.
I was running an older version of MySQL through WAMP, and just migrated the databases to an IIS-based server with PHP and MySQL 5.6 installed. For any query I run where not all columns of the table are specified, I receive a message such as:
Field 'J_param2' doesn't have a default value
All columns are TEXT and have the "NOT NULL" attribute set, but it's my understanding that NULL and an empty string are different. I'm fine with the empty string. Rather than altering the hundreds of tables, is there any easier way to fix this?
Thanks for the assistance.
You can remove the NOT NULL and you should be fine.
Try:
ALTER TABLE table_name MODIFY COLUMN J_param2 TEXT;
I'm using an INSERT ON DUPLICATE KEY statement for my website. It's for creating news items, so I figured I could use the same MySQL command for both creating and updating news items.
However, when I use the following:
INSERT INTO table (id,title,content) VALUES(NULL,"Test","Test");
Instead of creating a new auto increment value it throws an error. However, the command works on my main development server. But not on my laptop. Both versions of MySQL are the same, the only difference being MySQL was installed manually on my server, and with WAMP on my laptop.
Are there any MySQL Variables that could be causing this?
I would suggest using INSERT INTO table (title,content) VALUES("Test","Test");
This will create a new row in the table with a new incremented ID.
Managed to solve it as best as I can.
I checked my code and found that when I inserted the empty POST'd ID was wrapping it in quotations. I've now changed it so that it puts NULL without quotations. So my query should now look like:
INSERT INTO table (id,title,content) VALUES(NULL,"test","Test")
ON DUPLICATE KEY UPDATE title=VALUES(title), content=VALUES(content);
That now works.
I think you should make query like this,
INSERT INTO table (title,content) VALUES("Test","Test");
If it still doesn't work then check if id column is set as auto-increment or not.