3

I've already searched and tried to fix error, but I couldn't do that. What's problem inside my code? I'll paste code and error below. As I understand its about type of data. If I make any grammer mistakes, sorry about that.

$sql = <<<SQL
    INSERT INTO karakter (KullanıcıAdı,uid,Isim,Cinsiyet,Irk,Boy,Kilo,Gün,Ay,Yıl,Güç,Bünye,Dayanıklılık,Çeviklik,Karizma,Zeka,İrade,Odaklanma,Ustalık,Ziraat,İşçilik,Aşçılık,Botanik,Balıkçılık,Dericilik,Marangozluk,Hekimlik,VahşiYaşam,DuvarUstalığı,Camcılık,Demircilik,Avcılık,Şarapçılık,Çekilme,Kalkan,Hançer,Kılıç,Balta,Gürz,Mızrak,Yay,Arbalet)
    VALUES ("$user","$uid","$isim","$cinsiyet","$irk","$boy","$kilo","$gun","$ay","$yil","$Güç","$Bünye","$Dayanıklılık","$Çeviklik","$Karizma","$Zeka","$İrade","$Odaklanma","$Ustalık",'$Ziraat',"$İşçilik","$Aşçılık","$Botanik","$Balıkçılık","$Dericilik","$Marangozluk","$Hekimlik","$VahşiYaşam","$DuvarUstalığı","$Camcılık","$Demircilik","$Avcılık","$Şarapçılık","$Çekilme","$Kalkan","$Hançer","$Kılıç","$Balta","$Gürz","$Mızrak","$Yay","$Arbalet")
    ON DUPLICATE KEY UPDATE
    KullanıcıAdı=VALUES(KullanıcıAdı),
    uid=VALUES(uid),
    Isim=VALUES(Isim),
    Cinsiyet=VALUES(Cinsiyet),
    Irk=VALUES(Irk),
    Boy=VALUES(Boy),
    Kilo=VALUES(Kilo),
    Gün=VALUES(Gün),
    Ay=VALUES(Ay),
    Yıl=VALUES(Yıl),
    Güç=VALUES(Güç),
    Bünye=VALUES(Bünye),
    Dayanıklılık=VALUES(Dayanıklılık),
    Çeviklik=VALUES(Çeviklik),
    Karizma=VALUES(Karizma),
    Zeka=VALUES(Zeka),
    İrade=VALUES(İrade),
    Odaklanma=VALUES(Odaklanma),
    Ustalık=VALUES(Ustalık),
    Ziraat=VALUES(Ziraat),
    İşçilik=VALUES(İşçilik),
    Aşçılık=VALUES(Aşçılık),
    Botanik=VALUES(Botanik)
SQL;

The error is:

Incorrect integer value: '' for column 'Ziraat' at row 1

4
  • easy to understand you can not pass empty value to a integer column. Commented Jun 27, 2016 at 11:48
  • so there's a empty variable before that code. am I right? Commented Jun 27, 2016 at 11:51
  • means either provide 0 or any other integer value. '' is string not integer Commented Jun 27, 2016 at 11:52
  • okay figured it out. I get it right. it's totally my fault. I couldn't set the variable. anyway thank you. :) Commented Jun 27, 2016 at 11:56

2 Answers 2

3

Based on error Incorrect integer value: '' for column 'Ziraat' at row 1:-

1.Either you didn't set the corresponding variable with any value which is going to insert in that column.

2.Or you are sending ''(empty string) to that column, and it refuses because column is integer type.

Solution:- set your corresponding variable of that column, with a correct integer value (0 or >0).

Note:- check and correct yourself.Thanks.

Sign up to request clarification or add additional context in comments.

Comments

3

Please check the datatype of the table field 'Ziraat'.The integer field will not accept ' ' as integer.' ' is string.You can give 0 or >0 any value in place of ' '.

1 Comment

Thanks :) I found the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.