ImagineCustoms
ImagineCustoms

Reputation: 29

Color Individual Variables With Javascript & PHP?

What am I doing wrong?

} else {
    $output = '<script type="text/javascript">jAlert("<font color="red">'$number1'</font>", "Alert Dialog Sample")</script>';
}

I am getting:

Parse error: syntax error, unexpected T_VARIABLE

Upvotes: 0

Views: 94

Answers (3)

sephoy08
sephoy08

Reputation: 1114

it should be like this

$output = '<script type="text/javascript">jAlert("<font color="red">'.$number1.'</font>", "Alert Dialog Sample")</script>';

}

Upvotes: 1

Jared
Jared

Reputation: 12524

You need to use the string concatenation operator.

} else {
    $output = '<script type="text/javascript">jAlert("<font color="red">' . $number1 . '</font>", "Alert Dialog Sample")</script>';
}

I would refrain from using the font tag though as it is deprecated.

Upvotes: 0

Hawili
Hawili

Reputation: 1659

You missed the dots around $number1 which is used for concatenation

    $output = '<script type="text/javascript">jAlert("<font color="red">'.$number1.'</font>", "Alert Dialog Sample")</script>';

Upvotes: 1

Related Questions