• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

If Statement&Equals

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic