Jump to content


Assignments in conditions

  • Please log in to reply
2 replies to this topic

#1 CLU



  • Member
  • PipPip
  • 24 posts

Posted 06 December 2011 - 06:01 AM

Hi Guys,

Just quick one, I completed ben's tut on CRUD with mysqli, within my editor (Netbeans) when using bind_param in regards to the used question marks for the values, i get a small warning stating "Possible accidental assignment, assignments in conditions should be avoided."

Code works fine, but can anyone explain what this might mean?

Any guidance on this would be appreciated.

Kind Regards.
  • 0

#2 Ben



  • Administrators
  • 5,682 posts
  • LocationGainesville, Florida

Posted 06 December 2011 - 11:34 AM

You'd have to post the code for me to be sure, but I believe it's complaining about lines like this:

if ($stmt = $mysqli->prepare("UPDATE players SET firstname = ?, lastname = ?
                                                WHERE id=?"))
You can safely ignore that warning, or rewrite it slightly:

$stmt = $mysqli->prepare("UPDATE players SET firstname = ?, lastname = ?
                                                WHERE id=?");
if ($stmt)

It's just that Netbeans is seeing the = within a if statement, and thinking that maybe you made a mistake and you meant to say "==" or another comparison operator. I believe you should be able to disable this warning if you want: http://forums.netbea.../topic8214.html
  • 0
Benjamin Falk
Falken Creative : Twitter

#3 CLU



  • Member
  • PipPip
  • 24 posts

Posted 07 December 2011 - 03:28 AM

Thanks Ben.
  • 0

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

★★★★★ 5 Star Rated Web Developer Course - check it out now!