Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

If Statement&Equals

 
Ekrem Altintas
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I wrote this code. If deger[0] equal to kelime I want to increase the value of sayi.But if block didn't work.What should I do?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some questions that may guide you towards an answer:

- What does "sonuc.first();" accomplish? Can you leave it out?

- What does "if block didn't work" mean? Are any of the if conditions true or false when they shouldn't?

- What is the value of "deger[0]" when it is first used? Has it been initialized?

- Why are deger and kont arrays, if they contain only a single element?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34422
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, don't you want to set kont and not deger in the update statement? deger has remained unchanged so you are setting kelime back to it's original value.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
Also, don't you want to set kont and not deger in the update statement? deger has remained unchanged so you are setting kelime back to it's original value.
I don't see any "update statement". There's an INSERT statement, which creates a new record having sayi=1. That part seems okay to me. But the inner "if" statement doesn't include a SQL UPDATE statement, so the database is not updated. Maybe that is what Ekrem meant by "didn't work".
 
Akin Demir
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your kelimeler table is there a column named sayi
 
Akin Demir
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what if your resultset contained only one row.
You call first() the cursor goes to the firs row then you call next() on rresultset
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic