• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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: 42024
916
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.
 
Sheriff
Posts: 28333
97
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
 
pie. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic