mcfmullen Posted June 26, 2010 Share Posted June 26, 2010 Here's my chunk of code: <?php if (trim($row['altPhoto']) == 'None') { ?> <td width="21%" rowspan="5"><a id="imageurl" ><img id="Rotating1" border="0"></img></a></td> <script language="JavaScript"> function RotateImages(Start) { var a = new Array("<?php echo "$img{$row['Photo']}"; ?>","<?php echo "$img{$row['altPhoto']}"; ?>"); var c = new Array("<?php echo $itemurl; ?>", "<?php echo $itemurl; ?>"); var b = document.getElementById('Rotating1'); var d = document.getElementById('imageurl'); if(Start>=a.length) Start=0; b.src = a[start]; d.href = c[start]; window.setTimeout("RotateImages(" + (Start+1) + ")",3000); } RotateImages(0); </script> <?php }else { ?> <td width="21%" rowspan="5"><img src="<?php echo "$img{$row['Photo']}"; ?>"></td> <?php } ?> The code is SUPPOSED to execute the else when altPhoto contains something other than 'None' but instead, it executes it when altPhoto does contain 'None'. Can someone explain why that is? In other words the code should be doing this when altPhoto = None: Does altPhoto contain None? If yes = show only Photo. If no = show javascript stuff. I guess the matter is whether the code is working backwards or I'm understanding the code backwards. Quote Link to comment https://forums.phpfreaks.com/topic/205960-code-is-working-backwards/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 26, 2010 Share Posted June 26, 2010 What does using var_dump($row['altPhoto']); right before the if() statement show? Quote Link to comment https://forums.phpfreaks.com/topic/205960-code-is-working-backwards/#findComment-1077719 Share on other sites More sharing options...
KevinM1 Posted June 27, 2010 Share Posted June 27, 2010 I just ran into issues using trim on a value within a conditional in another project. Try removing it. Quote Link to comment https://forums.phpfreaks.com/topic/205960-code-is-working-backwards/#findComment-1077754 Share on other sites More sharing options...
mcfmullen Posted June 27, 2010 Author Share Posted June 27, 2010 I got it working! The problem lied in MySQL where the database had somehow reconfigured itself to show NULL instead of None. I thank you for you time guys! Quote Link to comment https://forums.phpfreaks.com/topic/205960-code-is-working-backwards/#findComment-1077859 Share on other sites More sharing options...
PFMaBiSmAd Posted June 27, 2010 Share Posted June 27, 2010 the database had somehow reconfigured itself LOL. No, databases don't do things like that. They only do exactly what you tell them to do and you must always check that you have configured something the way you want or that your data is actually what you expect, especially when your code that is dependent on that data does not do what you expect. From my signature: Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect. Quote Link to comment https://forums.phpfreaks.com/topic/205960-code-is-working-backwards/#findComment-1077895 Share on other sites More sharing options...
mcfmullen Posted June 27, 2010 Author Share Posted June 27, 2010 Dunno what to say.. I wasn't outputting what i told it to but now it's fine so all is good Quote Link to comment https://forums.phpfreaks.com/topic/205960-code-is-working-backwards/#findComment-1077937 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.