/    Sign up×
Community /Pin to ProfileBookmark

This is basically my psudo code, but what is the correct way to write this line?

if($user_data[‘photoWeb’] = 0 and $user_data[‘eventType’] != Wedding){
<div class=”box”>
<?php include(‘whatsnew.php’); ?>
</div>
<?php } ?>

This is what I have now:

[code=php]
<?php if($user_data[‘photoWeb’]){ ?>
<div class=”box”>
<?php include(‘whatsnew.php’); ?>
</div>
<?php } ?>
[/code]

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@comptech520authorFeb 25.2006 — Would this work?
[code=php]
<?php if($user_data['photoWeb']=0 and $user_data['eventType'] != Wedding ){ ?>
<div class="box">
<?php include('whatsnew.php'); ?>
</div>
<?php } ?>[/code]
Copy linkTweet thisAlerts:
@Leipe_PoFeb 25.2006 — <?php

if($user_data['photoWeb']=0 and $user_data['eventType'] != Wedding ){

echo '<div class="box">';

include('whatsnew.php');

echo '</div>';

}

?>

remember that jumping in and out of php can be mutch more server heavy,

you can use echo 'blaat';(single qouted echo's) to echo large chuncks of html
Copy linkTweet thisAlerts:
@comptech520authorFeb 25.2006 — For some reason that does not seem to be working. Should there be quotes around 0 and wedding?

Is there a way to combine these 2 together?

If photoWeb = 1

</div>

If photoWeb = 0 and eventType != Wedding

show file whatsnew.php

</div>

This is the code I have for this:

[code=php]
<?php if($user_data['photoWeb']){ ?>
echo '</div>';
<?php } ?>
</div>

<?php
if($user_data['photoWeb']=0 and $user_data['eventType'] != Wedding ){
echo '<div class="box">';
include('whatsnew.php');
echo '</div>';
}
?>
[/code]
Copy linkTweet thisAlerts:
@Leipe_PoFeb 25.2006 — if you can tell me more behind the idea of the script maybe i can help you more, but why is:

<?php if($user_data['photoWeb']){ ?>

echo '</div>';

<?php } ?>

</div>

that used?
Copy linkTweet thisAlerts:
@NogDogFeb 25.2006 — <i>
</i>if($user_data['photoWeb'] [color=red]==[/color] 0 and $userdata['eventType'] != [color=red]"[/color]Wedding[color=red]"[/color]) {

A good way to avoid the =/== error is to type the literal value first and the variable second, as it will throw a parse error if you use "=":
[code=php]
if(0 = $user_data['photoWeb']) { // will throw an error
if(0 == $user_data['photoWeb']) { // will do what you want
[/code]
Copy linkTweet thisAlerts:
@comptech520authorFeb 25.2006 — Hi Again,

The photo web part works, so if 0 the file shows and if 1 file does not show.

If photoweb is 0 and eventType= Wedding file still shows.

Any other ideas?

This is the code:
[code=php]
<?php

if($user_data['photoWeb'] == 0 and $user_data['eventType'] != "Wedding") {
echo '<div class="box">';
include('whatsnew.php');
echo '</div>';
}
?>
[/code]
Copy linkTweet thisAlerts:
@NogDogFeb 25.2006 — Try echoing out the values of the two $user_data elements being tested. If for some reason they are not being set or are empty strings, then your test will still pass, as 0 == "" == FALSE == NULL. Also check that "Wedding" is spelled exactly the same with the same upper/lower case letters. A more thorough check would be:
[code=php]
if(isset($user_data['photoWeb']) and !empty($user_data['eventType']))
{
// use "===" to test if photoweb is zero AND numeric
if($user_data['photoWeb'] === 0 and $user_data['eventType'] != 'Wedding')
{
// do what needs doing here
}
}
else
{
// handle error for values not being set
}
[/code]
Copy linkTweet thisAlerts:
@SpectreReturnsFeb 25.2006 — remember that jumping in and out of php can be mutch more server heavy, you can use echo 'blaat';(single qouted echo's) to echo large chuncks of html[/QUOTE]

Wrong.

for outputting large blocks of text, dropping out of PHP parsing mode is generally more efficient than sending all of the text through echo() or print().[/QUOTE]
Copy linkTweet thisAlerts:
@Leipe_PoFeb 26.2006 — hmmzzz with discussion of all sorts of php developers it is clear to me that you must not belive everything thats in the php manual, but thats a whole other discussion...
×

Success!

Help @comptech520 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...