Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

comparing a string to a Mysql db result

Status
Not open for further replies.

diezy

Technical User
Sep 2, 2002
50
0
0
CA
i have an if state have is comparing a result from a database and submitted string from a form.

when i print them out they both print the same result
123456 (db result)

123456 (submitted form result)

however try to compare them to see if they are equal in a if statement, it comes out false.
<code>
if($obj_db->fetch_array('password')== $str_login_password)
{
//code
}
</code>

when i use the is_string() function on database result is says its not a string....but the submitted form result is?

now just to clearify some things....my field i have querying/retrieving is a varchar field.

anyone have any suggest to get around this so i can check for the same value (cause i know they are...just the variable types are not)

 
Try using the trim function

if($obj_db->fetch_array('password') == trim($str_login_password)) {
//code
}
 
This might be because 123456 is really an integer.

Try this:
Code:
if(trim("" . $obj_db->fetch_array('password') . "") == trim($str_login_password))

ps. this is as dirty as it gets!

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top