PDA

View Full Version : Trying to use if conditional but can't get it to work


RedTurtle
11-24-2012, 05:51 PM
I'm trying to use the code below to make the following happen:

If $show['spelling_checker'] OR $show['infraction_checker'] are true AND $vbulletin->GPC['accept_rules'] is not true, then show the error code.

Also, if $show['intro_checker'] is true and $vbulletin->GPC['intro_rules'] is not true, also show the error code.

I'm trying to put them together in one combined statement, but not sure what I'm doing wrong.

if (($show['spelling_checker'] || $show['infraction_checker']) && !$vbulletin->GPC['accept_rules']) || if($show['intro_checker'] && !$vbulletin->GPC['intro_rules'])
{
$errors[] = "<span style='color: #ba0000; background-color: #FDFD65;'>Please accept the highlighted rules shown below before submitting your post.</span>";
}

Lynne
11-24-2012, 05:58 PM
You don't have () around the full condition and you have an extra if:

if ((($show['spelling_checker'] || $show['infraction_checker']) && !$vbulletin->GPC['accept_rules']) || ($show['intro_checker'] && !$vbulletin->GPC['intro_rules']))

RedTurtle
11-24-2012, 06:10 PM
Thank you Lynne. :)