Jump to content

[SOLVED] If statement not working


jaxdevil

Recommended Posts

Something is wrong in my if statement, somehow. I below is the top of the function (the whole thing is way to big to post, but its this one section that is a problem)

 

<?
		$q = "SELECT * FROM shipto_database WHERE shipto_code = '0000001' LIMIT 1";
		$res = mysql_query($q);
		while ($row = mysql_fetch_array($res)) {
			$shipto_saddressx = $row["shipto_saddress"];
echo $shipto_saddress;
echo "<br>";
echo $shipto_saddressx;
echo "<br>";
		}
if ($shipto_saddress != $shipto_saddressx) {

Code that should NOT be running if those two things match, and they do, but it still runs.

}

 

I have echoed both the variables on the screen, and they are exactly the same data, verbatim it outputs:

 

650 NW 123rd ST

650 NW 123rd ST

 

It should not run the insert query below the if statement, but it does. Any ideas what is wrong in the above, I can't find it.

 

Thanks,

SK

Link to comment
https://forums.phpfreaks.com/topic/129400-solved-if-statement-not-working/
Share on other sites

Oh thank god! I fixed it with your suggestion. Here is my fixed code:

 

<?
$shipto_address_temp = str_replace(' ', '', $shipto_saddress);

		$q = "SELECT * FROM shipto_database WHERE shipto_code = '0000001' LIMIT 1";
		$res = mysql_query($q);
		while ($row = mysql_fetch_array($res)) {
			$shipto_saddressx = $row["shipto_saddress"];
$shipto_addressx_temp = str_replace(' ', '', $shipto_saddressx);
echo $shipto_saddress;
echo "<br>";
echo $shipto_saddressx;
echo "<br>";
		}
if ($shipto_saddress_temp != $shipto_saddressx_temp) {

 

Thanks!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.