I used this example : http://woork.blogspot.com/2007/10/insert-record-into-database-using-ajax.html
it is working when using with Numbers for example if i enter number in these textbox it is work but when i enter string i get this error: "Unknown column 'text' in 'field list'"
'text' is text that write in the textbox instead of 'text' i write '123' it is working
Could you please suggest me way urgent.
Thanks all,
This error means that in your table there is no column named text. To fix this, either rename the field you wish to update/insert to text, or figure out which column you really wish to update/insert the text into.
Since your field is going to be updating/inserting a string, you need to also make sure you wrap the string in quotes.
INSERT INTO `table` (`val1`,`val2`) VALUES('".$val1."','".$val2."')
Make sure your column has a text or varchar datatype. Theoretically it should throw a different error if that was the case. But the fact that you're able to insert numbers and not text makes me think you've got some sort of INT datatype.
Obviously most importantly make sure your hello table really exists.
Related
Context, using doctrine to store an array as longtext in mysql column. Received some Notice: unserialize(): Error at offset 250 of 255 bytes.I therefore did some backtracking to realize the serialized string was truncated because its too big for a long text column. I really doubt that is the case. This string is near and far away from being 4GB.
Someone from this question suggested to take a look at SET max_allowed_packet but mine is 32M.
a:15:{i:0;s:7:"4144965";i:1;s:7:"4144968";i:2;s:7:"4673331";i:3;s:7:"4673539";i:4;s:7:"4673540";i:5;s:7:"4673541";i:6;s:7:"5138026";i:7;s:7:"5140255";i:8;s:7:"5140256";i:9;s:7:"5140257";i:10;s:7:"5140258";i:11;s:7:"5152925";i:12;s:7:"5152926";i:13;s:7:"51
Mysql table collation: utf8_unicode_ci
Any help would be greatly appreciated !!
Full Error
Operation failed: There was an error while applying the SQL script to the database.
ERROR 1406: 1406: Data too long for column 'numLotCommuns' at row 1
SQL Statement:
UPDATE `db`.`table` SET `numLotCommuns`='a:15:{i:0;s:7:\"4144965\";i:1;s:7:\"4144968\";i:2;s:7:\"4673331\";i:3;s:7:\"4673539\";i:4;s:7:\"4673540\";i:5;s:7:\"4673541\";i:6;s:7:\"5138026\";i:7;s:7:\"5140255\";i:8;s:7:\"5140256\";i:9;s:7:\"5140257\";i:10;s:7:\"5140258\";i:11;s:7:\"5152925\";i:12;s:7:\"5152926\";i:13;s:7:\"51}' WHERE `id`='14574'
The column was a tinytext...
Only logical explanation I can understand from this is that whether when I created my table in earlier version of doctrine, the default was tiny text
OR
I remember changing the type of the column within doctrine annotations and maybe the update didn't fully convert the type correctly.
Bottom line, check your types even though you use an orm.
Your column must have been defined as varchar(250).
You need to first convert it to the longtext.
In my database table, I have a field where I am storing userid's as comma separated values like 1,2,3 etc. Each user id's are added to the field through updation at a certain point. So if field contain value 1, then I want to append new userid as ,2 on next updation so that all values will be separated by comma.
I am using the following mysql for it:
"UPDATE videorating
SET total_votes='".$added."',
total_value='".$sum."',
userid=CONCAT(userid,',$userid'),
used_ips='".$insertip."'
WHERE videoid='$id_sent'";
Here $userid will contain the userid. But this is not working properly. The field is not getting updated. What is wrong with this query.
Can anyone help me to fix this. Thanks in advance.
I am not sure if your userid column really is varchar or not? If it is varchar (or some other text based) then your code should work. This is the same as your but with too many quotes:
UPDATE videorating
SET total_votes='$added',
total_value='$sum',
userid=CONCAT(userid,',$userid'),
used_ips='$insertip'
WHERE videoid='$id_sent'";
If it in fact is an int you cannot do it like this and you need to rethink what you want to archieve.
I have been looking for this problem since a while so I guess I stuck.
Case is: I'm importing a large csv file into mysql database with Bigdump (thanks to A. Ozerov), delimiter is |, all is fine, this works.
In my last varchar field the values are usually: '', 'X', '1', '0'. Problem is if I do a select query to this field and look up values with '', I find none or one only. I checked a few lines one by one and found that the phpmyadmin shows a "textarea" instead of a textbox. I went and selected the field data and nothing was there (not even a carriage return). Still I could save the line and reopen it, when the textarea changed to textbox.
I wonder if anyone ever saw this error, and if there is a way to fix this database runtime from php (part of daily process), not line-by-line.
I even tried to copy paste both the csv and the database field to text editor to see if a char is there that I don't see.
The data I want to use is:
0 if the value is empty, 1 if the value is anything else. Currently I am not able to separate this two for the above reason.
Thank you in advance!
Check for hexcidecimal values in the column by doing this:
SELECT HEX(columnname)
Then use REPLACE to change the Hex values to Null or ''
I have written a stored procedure in mysql to update. That is working fine, when you execute it in the mysql command line(through Mysql editor).
Stored procedure is:
CREATE DEFINER=`root`#`localhost` PROCEDURE `Deduction_Of_PL`(
IN P_EMPID VARCHAR(1000)
)
BEGIN
DECLARE PresentYearPL VARCHAR(1000);
set PresentYearPL=(select Present_Year_PL from leave_calculate_pl where employee_id=P_EMPID);
IF(PresentYearPL<=0) THEN
UPDATE leave_calculate_pl
SET Carrie_PL=Carrie_PL-1
where employee_id=P_EMPID;
ELSE
UPDATE leave_calculate_pl
SET Present_Year_PL=Present_Year_PL-1
where employee_id= P_EMPID;
END IF;
END $$
And I calling the same Stored procedure in PHP, I am passing the input parameter also.
$LeaveTypeID_G=$this->getLeaveTypeId();
$query_G="CALL Deduction_Of_PL($LeaveTypeID_G)";
Its giving the error as
Unknown column 'parameter_value' in 'field list' MySQL Error # :1054
Please let me know where went wrong and how can I resolve it.
I've just come up against the same issue. I'm trying to pass a logged in user's username to the stored procedure to record it in a log.
The Stored Procedure runs fine when I call it directly (from MySQL Workbench) and was working fine from PHP when I was only passing a date/time. Now that I'm passing this username as a string, however it broke.
For me the fix was to enclose any string parameters in single quote, something like this:
$query = "CALL $procedure_name ( $date_parameter, '$string_parameter')";
Hope that helps anyone else stumbling across this.
well I'm not an expert on sql, and I don't see much php code posted but "Unknown column" to me would be refering to the column names in the sql table in question, or more precisely that it can't find the column you told it to get in that table. first place I'd look at is the select statement your asking it to pull from the column "Present_Year_PL" I found this to be case senstive so make sure it matches excatly the column name on the table. next place I'd look is in the where statement you told it to match agist the colum "employee_id" now this is all lower case as oposed to your prevous column name that was all caps, while this is technicaly legal, (As on the actual table you could have one column in all caps and one in all lower,) usally if all caps are used in one column name in a table all the column names are done the same, and vice versa. this would cause a problem your having if say the "employee id" column on the table is "EMPLOYEE_ID" as then "employee_id" actualy does not exist in the table. also be sure your not dooing sometthing like "employeeid" or "employee-id" or even "employee id" as those are verry easy to mistake when eyeballing the field name but will give you the error your getting.
couple of pointers:
what is the value of the php variabele $LeaveTypeID_G? echo $LeaveTypeID_G; (php)
secondly is MySql invoking a trigger? show triggers; (mysql)
i echoed the query below: (query is safe)
UPDATE otelozellik
SET isim_tr='test',
aciklama_tr='<p>test1</p>',
uyari_tr='test',
tag_tr='test'
WHERE id='1'
Database Error: Unknown column
'aciklama_tr' in 'field list'
I changed the order of columns, the one after isim_tr keeps giving error. When I move isim_tr to the last then the one after id giving the same error. But moving them to the last position is not a solution for me because table will be dynamic to add new columns when necessary. need an absolute solution.
UPDATE: LATEST SCREENSHOT: http://img5.imageshack.us/img5/7215/mysqlerror.jpg
Solved. Solution is answered below. Thanks everyone.
Problem is solved. Thank you a lot everyone for their help.
Right Query for solution is:
UPDATE `holidaycholic`.`otelbilgi` SET `otelbilgi`.`isim_tr`='test2', `otelbilgi`.`aciklama_tr`='<p>test2</p>', `otelbilgi`.`uyari_tr`='test2', `otelbilgi`.`tag_tr`='test2' WHERE `otelbilgi`.`id`=1
No idea why but that worked for me.
'field list' errors are caused when you try to load data into a field that doesn't exist. Double check that you spelled your field names correctly.
Your post says that you need to add "dynamic columns". A properly structured database shouldn't have a need for that sort of thing. However, if you do want to add columns from php, you need to add them to the table before you try to insert data in those fields. You can use the ALTER TABLE statement to do this:
ALTER TABLE table_name
ADD column_name datatype
Just to double-check are all the characters you're using the standard ASCII characters or are you using an unusual character set?
Try inserting data into the table using phpMyAdmin or similar - If it works, copy the code it generates and run it yourself using the mysql client.
Assuming that still works, compare the generated code with the SQL generated by your PHP
Here is the syntax which works for me all time:
"INSERT INTO table(`code`, `description`) VALUES ('".mysql_real_escape_string($code)."', '".mysql_real_escape_string($description)."')";
"table" is a table with an AUTO_INCREMENT index.