almightyegg Posted January 24, 2007 Share Posted January 24, 2007 I have this code and my test user has info filled in their mysql row but still it says 'gah' to show an error :(I am really stuck!! please help ;D[code=php:0]<? if($profile['customt1']==0){echo "gah";}else{ ?><tr><td valign="top"><b><? echo "$profile[customt1]"; ?></b> </td><td valign="top"><? echo "<p>$profile[customtext1]</p>"; ?></td></tr><? } if($profile['customt2']==0){echo "gah";}else{ ?><tr><td valign="top"><b><? echo "$profile[customt2]"; ?></b></td><td valign="top"><? echo "<p>$profile[customtext2]</p>"; ?></td></tr><? } if($profile['customt3']==0){echo "gah";}else{ ?><tr><td valign="top"><b><? echo "$profile[customt3]"; ?></b> </td><td valign="top"><? echo "<p>$profile[customtext3]</p>"; ?></td></tr><? } ?>[/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 24, 2007 Share Posted January 24, 2007 Post the code where you get $profile Quote Link to comment Share on other sites More sharing options...
almightyegg Posted January 24, 2007 Author Share Posted January 24, 2007 Well, I know it isn't wrong with that as I have used else where but here:[code=php:0]$id = $_GET['id'];$first = "SELECT * FROM users WHERE id = '$id'";$second = mysql_query($first);$profile = mysql_fetch_assoc($second);[/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 24, 2007 Share Posted January 24, 2007 Under that, do print_r($profile); and see what it says for customt1. Paste the print_r() result here? Quote Link to comment Share on other sites More sharing options...
almightyegg Posted January 24, 2007 Author Share Posted January 24, 2007 [customt1] => Music It recognises it fine, all of the bits im trying to do come out fine ??? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 24, 2007 Share Posted January 24, 2007 Instead of comparing it to 0, try checking if it is set. If I recall correctly, if($profile['customt1']==0){Will convert $profile['customt1'] to a number. Since it's not a number, it turns into 0. Thus, TRUE.Tryif(!isset($profile['customt1'])){// gah} Quote Link to comment Share on other sites More sharing options...
almightyegg Posted January 24, 2007 Author Share Posted January 24, 2007 stops all info from being displayed.... :-[ Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 24, 2007 Share Posted January 24, 2007 Now it doesn't display gah or your table?What aboutif(empty($profile['customt1'])){ Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted January 24, 2007 Share Posted January 24, 2007 it will have to be something like:if (!$profile['custom1'])) {echo 'gah';}Granted empty might work to, but I use the ! and it works fine on my sites. Quote Link to comment Share on other sites More sharing options...
almightyegg Posted January 24, 2007 Author Share Posted January 24, 2007 [quote author=jesirose link=topic=123854.msg512514#msg512514 date=1169663792]Now it doesn't display gah or your table?What aboutif(empty($profile['customt1'])){[/quote]It wouldn't display any of the page ???[quote author=steelmanronald06 link=topic=123854.msg512516#msg512516 date=1169663925]it will have to be something like:if (!$profile['custom1'])) {echo 'gah';}Granted empty might work to, but I use the ! and it works fine on my sites.[/quote]It worked!!!! Thank you muchly! ;D Quote Link to comment 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.