Enum data-field in XAMPP - php

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.

Related

Query not working in Mysql database

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.

Migrated MySQL database, now seeing "Field doesn't have a default value"

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;

error while inserting null data in mysql phpmyadmin

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

Alter Tabled using PHP Query, Column Name doesn't show up in phpMyAdmin

This is my first post, and there is a similar post here: phpMyAdmin doesn't show added columns - Stack Overflow
But since no one has answered, I will ask here and provide more details in hoping to resolve this issue. I have a table in my database that I needed to be able to add additional columns to. I've done this using the following query:
$sql = "ALTER TABLE tablename ADD columnname INT(11)"; //Run the query....
This worked perfect on day one, however on day two when I tried to add an additional column via this php script, it appears to work from the phpMyAdmin Structure view. The column is in there with the correct columnname and datatype. However when I switch to the Browse view, there is no Column Name, just blank columns filled with "null" values. But, if you click on an individual row, it shows the correct column name, and a value (if one exists for that row).
I've tried running Analyze Table, as I read somewhere that that would update the Schema. However, I haven't had any success with that fixing it. I'd prefer to not have to delete the table and restart, especially if I run into this issue again. As this is my first post, I've tried to format everything correctly, but please forgive me if I didn't. Also, I can grab screenshots if anyone is having issues understanding my question.
if you can, restart mysql, it should flush everything, including mysql caches phpmyadmin may be using.

Should I be able to update a MySQL enum type with a text value?

I'm trying to update the value in a MYSQL enum field from PHP via Doctrine (5.3 and 1.2 respectively).
I get an error when I try and do this:
$q = Doctrine_Query::create()
->update('StMessages')
->set('status','new')
->where('message_id = ?',$msg_id);
I get a sql state error telling me that the column 'new' does not exist. If I enter 3 instead of new (presumably the internal index of the 'new' value), then the query works. In fact it happens in a SQL client too so perhaps this is a quirk of this version of MySQL? Its 5.1.45.
Anyone know if this is how MySQL is supposed to treat enums or if this is more likely a Doctrine issue? I have 'use_native_enum' set to true.
Given a table
create table test (
enumfield enum('a','b','c')
);
you should be able to do
update test set enumfield='a';
which is the whole point of the num field - not having to mess with indexes and whatnot.
What's the exact definition of your enum field?
I think this was actually an issue relating to the quoting of strings when updating the field's values. I'm not sure if Doctrine or I was at fault.

Categories