# \[help\] comparing variable values?

**URL:** <https://forum.kirupa.com/t/help-comparing-variable-values/246143>\
**Category:** Uncategorized\
**Created:** [December 7, 2007, 2:53pm UTC](https://forum.kirupa.com/t/help-comparing-variable-values/246143 "2007-12-07T14:53:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjj](https://avatars.discourse-cdn.com/v4/letter/c/ecc23a/32.png) [@cjj](https://forum.kirupa.com/u/cjj)\
**Post date:** [December 7, 2007, 2:53pm UTC](https://forum.kirupa.com/t/help-comparing-variable-values/246143/1 "2007-12-07T14:53:00Z")

</div>

I hope someone can help me.

I’m busy with a php script and I’m reading variables from my database and comparing it with another variable.

$get\_item = "select \* from item\_pics WHERE user = ‘something’ ";  
$get\_item\_res = mysql\_query($get\_item) or die (mysql\_error());

$item\_name1 = stripslashes(mysql\_result($get\_item\_res,0,’$item\_name1’));

$item\_1 = stripslashes(mysql\_result($get\_item\_res,0,‘item\_1’));  
$item\_2 = stripslashes(mysql\_result($get\_item\_res,0,‘item\_2’));

if ( ($item\_name == ‘$item\_1’) || ($item\_name == ‘$item\_2’) ) {  
echo “ITS THE SAME”;  
}

If I do a echo on the value of the variables it shows that $item\_name and $item\_2 have the same value. But using this script above it doesn’t seem to read that they have the same value. But if I change ($item\_name == ‘$item\_2’) to ($item\_name == ‘thevalue’) then it works

What am I doing wrong? I would really appreciate any help. Thanks ! :sigh::sigh:
