MyBB Central

Full Version: Simple code help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Okay, I've started coding a coin flip MyCode in PHP, but I keep getting an unexpected T_STRING on line 38. I've checked for semicolons, tried putting semicolons like everywhere, but I cannot fix the problem, any help?

Code:
<?php
// Coin Flip Mycode
// By Innocence
// Version 1.0


$plugins->add_hook("parse_message", "coinflip_run");


function coinflip_info()
{
    return array(
        "name"            => "Coin Flip BBCode",
        "description"    => "Coin Flip BBCode",
        "website"        => "supermariorp.890m.com/Forum/",
        "author"        => "Innocence",
        "authorsite"    => "supermariorp.890m.com/Forum/",
        "version"        => "1.0",
    );
}


function coinflip_activate()
{
}


function coinflip_deactivate()
{
}


function coinflip_run($message)
{
    return preg_replace('#\[coinflip\]#i', "<?php
$num=rand(0, 1);
if ($num=0)
$coin="Heads";
else
$coin="Tails";
echo $coin; ?>", $message);
}


?>
You've set the if-comdition wrong: You forgot the "{" and "}"
PHP Code:
function coinflip_run($message)
{
    return 
preg_replace('#\[coinflip\]#i'"<?php
$num=rand(0, 1);
if (
$num=0)
{
$coin="Heads";
}
else
{
$coin="Tails";
}
echo 
$coin; ?>"$message);