arunkar Posted March 31, 2008 Share Posted March 31, 2008 Hi experts, Im doing a simple logical statement, I'm pulling out the data from the database and if the count result from DB is 0 then I do not want to display a link. Else if there is a number I want to display a link. I did a very simple if statement but it throws a error below: Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in /chroot/home/dashboard/index.php on line 81 Code: <?php foreach($rowWC as $fieldName => $field) // line 81 { if($field >0) {echo "<a href='javascript:popUp('details.php?MR=WC')'>" $field "</a>"; } else {echo "0";} }?> could advice please? cheers Arun Link to comment https://forums.phpfreaks.com/topic/98826-a-simple-display-logical-error/ Share on other sites More sharing options...
uniflare Posted March 31, 2008 Share Posted March 31, 2008 Parse error is a code syntax error not logic . unexpected T_VARIABLE means it saw a $ symbol where it shouldn't be, try this: <?php foreach($rowWC as $field) // line 81 { if($field >0) {echo "<a href='javascript:popUp('details.php?MR=WC')'>" $field "</a>"; } else {echo "0";} }?> Link to comment https://forums.phpfreaks.com/topic/98826-a-simple-display-logical-error/#findComment-505682 Share on other sites More sharing options...
arunkar Posted March 31, 2008 Author Share Posted March 31, 2008 Thanks uniflare, I did the changes: I put this code: <?php foreach($rowWC as $field) // line 81 { if($field >0) {echo "<a href='javascript:popUp('details.php?MR=WC')'>" $field "</a>"; //line 84 } else {echo "0";} }?> but it showed mew an error in line 84. what could have gorn? Link to comment https://forums.phpfreaks.com/topic/98826-a-simple-display-logical-error/#findComment-505697 Share on other sites More sharing options...
uniflare Posted March 31, 2008 Share Posted March 31, 2008 Ah dint notice that 1, you need concatenation (period)... ie; <?php foreach($rowWC as $field) // line 81 { if($field >0) {echo "<a href='javascript:popUp('details.php?MR=WC')'>" . $field . "</a>"; //line 84 } else {echo "0";} }?> Also try structuring your code a little differently: <?php foreach($rowWC as $field){ // line 81 if($field >0){ echo "<a href='javascript:popUp('details.php?MR=WC')'>" . $field . "</a>"; //line 84 }else{ echo "0"; } }?> hope this helps, Link to comment https://forums.phpfreaks.com/topic/98826-a-simple-display-logical-error/#findComment-505729 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.