0

I have a PHP website setup on my local host (XAMPP) and online server. On local host when I try to run the website I get this error:

Parse error: syntax error, unexpected end of file in C:\XAMPP\htdocs\website\index.php on line 304

However the same code works fine on online server.

Here is the how it look like:

<?php
$file = "admin/data/home.txt";
$fileproduct = "admin/data/product.txt";
$fileseo = "admin/data/seohome.txt";
$filesm = "admin/data/smhome.txt";
$filevideo = "admin/data/video.txt";

if (file_exists($file)) $data = json_decode(file_get_contents($file));
if (file_exists($fileproduct)) $dataproduct = json_decode(file_get_contents($fileproduct));
if (file_exists($fileseo)) $dataseo = json_decode(file_get_contents($fileseo));
if (file_exists($filesm)) $datasm = json_decode(file_get_contents($filesm));
if (file_exists($filevideo)) $datavideo = json_decode(file_get_contents($filevideo));

    include('includes/header.php');

    switch($settings->currency) {
        case 'USD': $sym = '$'; break;
        case 'GBP': $sym = '£'; break;
        case 'EUR': $sym = '€'; break;
    }

$allDataSM = array(
    0 => array('title' => 'Twitter Followers', 'name' => 'tw_fo_tx', 'price' => 'tw_fo_pr', 'image' => 'twitter.png'),
    1 => array('title' => 'Instagram Followers', 'name' => 'in_fo_tx', 'price' => 'in_fo_pr', 'image' => 'instagram.png'),
    2 => array('title' => 'Facebook Like', 'name' => 'fb_lk_tx', 'price' => 'fb_lk_pr', 'image' => 'facebook.png'),
    3 => array('title' => 'Youtube Views', 'name' => 'yo_vw_tx', 'price' => 'yo_vw_pr', 'image' => 'youtube.png'),
    4 => array('title' => 'Twitter Retweet', 'name' => 'tw_rt_tx', 'price' => 'tw_rt_pr', 'image' => 'twitter.png'),
    5 => array('title' => 'Instagram Likes', 'name' => 'in_lk_tx', 'price' => 'in_lk_pr', 'image' => 'instagram.png'),
    6 => array('title' => 'Facebook Shares', 'name' => 'fb_sh_tx', 'price' => 'fb_sh_pr', 'image' => 'facebook.png'),
    7 => array('title' => 'Youtube Subscribes', 'name' => 'yo_su_tx', 'price' => 'yo_su_pr', 'image' => 'youtube.png')
);

$allDataSEO = array(
    0 => array('title' => 'BACKLINK PACKAGES', 'name' => 'tw_fo_tx', 'price' => 'tw_fo_pr', 'image' => 'backlinks.png'),
    1 => array('title' => 'PRESS RELEASES', 'name' => 'in_fo_tx', 'price' => 'in_fo_pr', 'image' => 'pressreleases.png'),
    2 => array('title' => 'CONTENT WRITING', 'name' => 'fb_lk_tx', 'price' => 'fb_lk_pr', 'image' => 'articlewriting.png'),
    3 => array('title' => 'ARTICLE SUBMISSIONS', 'name' => 'yo_vw_tx', 'price' => 'yo_vw_pr', 'image' => 'articlesubmission.png'),
    4 => array('title' => 'SOCIAL BOOKMARKING', 'name' => 'tw_rt_tx', 'price' => 'tw_rt_pr', 'image' => 'socialbookmarking.png'),
    5 => array('title' => 'VIDEO MARKETING', 'name' => 'in_lk_tx', 'price' => 'in_lk_pr', 'image' => 'videomarketing.png'),
    6 => array('title' => 'LINK INDEXING', 'name' => 'fb_sh_tx', 'price' => 'fb_sh_pr', 'image' => 'linkindexing.png'),
    7 => array('title' => 'SOCIAL ACCOUNTS', 'name' => 'yo_su_tx', 'price' => 'yo_su_pr', 'image' => 'socialaccounts.png')
);
?>
<!-- Site Description -->
<div class="presentation container">
    <h2><?php echo $data->main_headline != '' ? stripslashes($data->main_headline) : 'We are <span class="violet">SocialPiggy</span>, a viral marketing company.'; ?></h2>
    <p><?php echo $data->main_headline != '' ? stripslashes($data->sub_headline) : 'We create viral buzz around the internet...'; ?></p>
</div>
<?php if (isset($data->hero_enable) && $data->hero_enable == 1){  ?>
<div class="what-we-do container hero">
<div class="row">
<div class="span6 <?php echo $data->hero_video_position == "left"? "" : "right";  ?>">
<?php echo stripslashes($data->hero_video);  ?>
</div>

<div class="span6">
    <h2><?php echo $data->hero_title != '' ? stripslashes($data->hero_title) : 'We are <span class="violet">SocialPiggy</span>, a viral marketing company.'; ?></h2>
    <p><?php echo $data->hero_desc != '' ? stripslashes($data->hero_desc) : 'We create viral buzz around the internet...'; ?></p>
</div>
</div>
</div>
<?php }  ?>
<?php
    $fixed_str = '  <input type="hidden" name="cmd" value="_cart">
                    <input type="hidden" name="business" value="'.$settings->paypal.'">
                    <input type="hidden" name="lc" value="US">
                    <input type="hidden" name="add" value="1">';
    $btn = '<input type="submit" class="btn_new" value="Buy Now" />';
?>
    <!-- Videos -->
<?php if (isset($datavideo->video_enable) && $datavideo->video_enable == 1){  ?>
    <div class="what-we-do container">
        <div class="row">
            <?php

            for ($i = 1; $i < 5; $i++) {

                for ($j = 1; $j <= $settings->total_videos; $j++)
                {
                    if ($datavideo->video_name->$j == $data->video->$i)
                    {
                        ?>
                        <div class="service span6 productbox">
                            <p class="mg15"></p>
                            <div class="">
                                <?php echo '<iframe width="560" height="280" src="'.str_replace("watch?v=", "embed/",$datavideo->link->$j).'?showinfo=0&controls=0&rel=0" frameborder="0" allowfullscreen></iframe>'; ?>
                            </div>
                            <div class="left span5 spleft"><h4><?php echo stripslashes($datavideo->video_name->$j); ?></h4><p><?php echo stripslashes($datavideo->video_desc->$j); ?></p>
                                <!-- <p></p>Price : <?php echo $sym. $datavideo->price->$j; ?><br><p></p><p></p>-->
                                <form id="signup" action="<?php echo paypal_path; ?>" method="post">
                                    <input type="hidden" name="cmd" value="_cart">
                                    <input type="hidden" name="business" value="<?php echo $settings->paypal; ?>">
                                    <input type="hidden" name="lc" value="US">
                                    <input type="hidden" name="add" value="1">
                                    <input type="hidden" name="item_name" value="<?php echo stripslashes($datavideo->video_name->$j); ?>">
                                    <input type="hidden" name="amount" value="<?php echo $datavideo->price->$j; ?>">
                                    <input type="hidden" name="return" value="<?php echo 'http://' . $_SERVER['HTTP_HOST'] . '/thankyou.php'; ?>">
                                    <input type="hidden" name="currency_code" value="<?php echo $settings->currency; ?>">
                                    <!-- <input type="image" src="images/bn.png" border="0" name="submit"> -->
                                    <?php echo '<input type="submit" class="btn_new" value="'.$datavideo->video_buy_button->$j.' for '.$sym. trim($datavideo->price->$j).'">'; ?>
                                </form>
                            </div>
                            <div class="clear"></div>
                        </div>

                    <?
                    }
                }
            }
            ?>
        </div>
    </div>
<?php } ?>
<!-- Products -->
<?php if (1==2 && isset($dataproduct->product_enable) && $dataproduct->product_enable == 1){  ?>
<div class="what-we-do container">
    <div class="row">
        <?php

for ($i = 1; $i < 5; $i++) {

    for ($j = 1; $j <= $settings->total_products; $j++) {
        if ($dataproduct->product_name->$j == $data->product->$i)
        {
            ?>
            <div class="service span6 productbox">
                <p class="mg15"></p>
                <div class="left span2">
                    <div class="icon-awesome "> <img src="http://<?php echo $_SERVER['HTTP_HOST']; ?>/admin/data/images/<?php echo $dataproduct->product_img->$j; ?>" style="max-width:150px;"> </div>
                </div>
                <div class="left span3 spleft"><h4><?php echo stripslashes($dataproduct->product_name->$j); ?></h4><p><?php echo stripslashes($dataproduct->product_desc->$j); ?></p>
                <p></p>Price : <?php echo $sym . $dataproduct->price->$j; ?><br><p></p><p></p>
                    <form id="signup" action="<?php echo paypal_path; ?>" method="post">
                        <input type="hidden" name="cmd" value="_cart">
                        <input type="hidden" name="business" value="<?php echo $settings->paypal; ?>">
                        <input type="hidden" name="lc" value="US">
                        <input type="hidden" name="add" value="1">
                        <input type="hidden" name="item_name" value="<?php echo stripslashes($dataproduct->product_name->$j); ?>">
                        <input type="hidden" name="amount" value="<?php echo $dataproduct->price->$j; ?>">
                        <input type="hidden" name="return" value="<?php echo $dataproduct->link->$j; ?>">
                        <input type="hidden" name="currency_code" value="<?php echo $settings->currency; ?>">
                        <!-- <input type="image" src="images/bn.png" border="0" name="submit"> -->
                        <?php echo $btn; ?>
                    </form>
                    </div>
                <div class="clear"></div>
            </div>

            <?
        }
    }
}
        ?>
    </div>
</div>
<?php } ?>
<!-- SEO -->
<?php if (isset($dataseo->seohome_enable) && $dataseo->seohome_enable == 1){  ?>
<div class="presentation container">
    <h2><?php echo $dataseo->main_headline != '' ? stripslashes($dataseo->main_headline) : 'We are <span class="violet">SocialPiggy</span>, a viral marketing company.'; ?></h2>
    <p><?php echo $dataseo->main_headline != '' ? stripslashes($dataseo->sub_headline) : 'We create viral buzz around the internet...'; ?></p>
</div>
<div class="what-we-do container">
    <div class="row">
<?php

for ($t = 1; $t < 5; $t++) {

    for ($j = 0; $j < count($allDataSEO); $j++) {
        if ($allDataSEO[$j]["name"] == $data->seoservice->$t)
        {
            ?>
        <div class="service span3">
            <div class="icon-awesome"><img src="images/<?php echo $allDataSEO[$j]["image"]; ?>"></div>
            <h4><?php echo $allDataSEO[$j]["title"]; ?></h4>
            <p></p>
            <form id="signup" action="<?php echo paypal_path; ?>" method="post">
                <input type="hidden" name="item_name" value="<?php echo $allDataSEO[$j]["title"]; ?>">

                <?php echo $fixed_str; ?>
                <input type="hidden" name="on0" value="Selected value ">
                <?php
                    for($tmp = 1; $tmp <= count((array)$dataseo->$allDataSEO[$j]["name"]); $tmp++) {
                        echo '<input type="hidden" name="option_select'.$tmp.'" value="'.filter_var($dataseo->$allDataSEO[$j]["name"]->$tmp, FILTER_SANITIZE_NUMBER_INT).'">';
                        echo '<input type="hidden" name="option_amount'.$tmp.'" value="'.$dataseo->$allDataSEO[$j]["price"]->$tmp.'">';
                    }
                ?>
                <div class="styled-select">
                    <select name="os0">
                        <?php
                            $tmp = 1;
                            for($i = 1; $i <= count((array)$dataseo->$allDataSEO[$j]["name"]); $i++) {
                                echo '<option value="'. filter_var($dataseo->$allDataSEO[$j]["name"]->$i, FILTER_SANITIZE_NUMBER_INT).'">'.$dataseo->$allDataSEO[$j]["name"]->$i.' - '.$sym.$dataseo->$allDataSEO[$j]["price"]->$i.'</option>';
                                $tmp++;
                            }
                        ?>
                    </select>
                </div>
                <input type="hidden" name="return" value="<?php echo 'http://' . $_SERVER['HTTP_HOST'] . '/thankyou.php'; ?>">
                <input type="hidden" name="on1" value="SiteURL:"> Enter URL
                <input class="tb7" type="text" name="os1" id="TwitterRetweet" maxlength="200">
                <input type="hidden" name="currency_code" value="<?php echo $settings->currency; ?>"><br>
                <center><!-- <input type="image" src="images/bn.png" border="0" name="submit"> --> <?php echo $btn; ?></center>
            </form>
            <p></p>
        </div>
        <?
        }
    }
}
?>
    </div>
</div>
    <?php } ?>
<?php if (isset($datasm->smhome_enable) && $datasm->smhome_enable == 1){  ?>
<!-- Social Media -->
<div class="presentation container">
    <h2><?php echo $datasm->main_headline != '' ? stripslashes($datasm->main_headline) : 'We are <span class="violet">SocialPiggy</span>, a viral marketing company.'; ?></h2>
    <p><?php echo $datasm->main_headline != '' ? stripslashes($datasm->sub_headline) : 'We create viral buzz around the internet...'; ?></p>
</div>
    <div class="what-we-do container">
        <div class="row">
            <?php

            for ($t = 1; $t < 5; $t++) {

                for ($j = 0; $j < count($allDataSM); $j++) {
                    if ($allDataSM[$j]["name"] == $data->smservice->$t)
                    {
                        ?>
                        <div class="service span3">
                            <div class="icon-awesome"><img src="images/<?php echo $allDataSM[$j]["image"]; ?>"></div>
                            <h4><?php echo $allDataSM[$j]["title"]; ?></h4>
                            <p></p>
                            <form id="signup" action="<?php echo paypal_path; ?>" method="post">
                                <input type="hidden" name="item_name" value="<?php echo $allDataSM[$j]["title"]; ?>">

                                <?php echo $fixed_str; ?>
                                <input type="hidden" name="on0" value="Selected value " />
                                <?php
                                for($tmp = 1; $tmp <= count((array)$datasm->$allDataSM[$j]["name"]); $tmp++) {
                                    echo '<input type="hidden" name="option_select'.$tmp.'" value="'.filter_var($datasm->$allDataSM[$j]["name"]->$tmp, FILTER_SANITIZE_NUMBER_INT).'">';
                                    echo '<input type="hidden" name="option_amount'.$tmp.'" value="'.$datasm->$allDataSM[$j]["price"]->$tmp.'">';
                                }
                                ?>
                                <div class="styled-select">
                                    <select name="os0">
                                        <?php
                                        $tmp = 1;
                                        for($i = 1; $i <= count((array)$datasm->$allDataSM[$j]["name"]); $i++) {
                                            echo '<option value="'. filter_var($datasm->$allDataSM[$j]["name"]->$i, FILTER_SANITIZE_NUMBER_INT).'">'.$datasm->$allDataSM[$j]["name"]->$i.' - '.$sym.$datasm->$allDataSM[$j]["price"]->$i.'</option>';
                                            $tmp++;
                                        }
                                        ?>
                                    </select>
                                </div>
                                <input type="hidden" name="return" value="<?php echo 'http://' . $_SERVER['HTTP_HOST'] . '/thankyou.php'; ?>">
                                <input type="hidden" name="on1" value="SiteURL:"> Enter URL
                                <input class="tb7" type="text" name="os1" id="TwitterRetweet" maxlength="200">
                                <input type="hidden" name="currency_code" value="<?php echo $settings->currency; ?>"><br>
                                <center><!-- <input type="image" src="images/bn.png" border="0" name="submit"> --> <?php echo $btn; ?></center>
                            </form>
                            <p></p>
                        </div>
                    <?
                    }
                }
            }
            ?>
        </div>
    </div>
<?php } ?>
<!-- Latest Work -->

<?php if ($settings->total_testi > 0) { ?>
    <!-- Testimonials -->
    <div class="testimonials container">
        <div class="testimonials-title">
            <h3>Testimonials</h3>
        </div>
        <div class="row">
            <div class="tab-content">
                <?php 
                    for($i = 1; $i <= $settings->total_testi; $i++) {
                        echo '
                            <div class="testimonial-list">
                                <img src="admin/data/images/'.$data->testi_img->$i.'" title="" alt="">
                                <p>'.stripslashes($data->testi_msg->$i).'<br><span class="violet" style="color: '.$settings->dark_color.';">'.$data->testi_auth->$i.'</span></p>
                            </div>
                        ';
                    }
                ?>
            </div>
        </div>
    </div>
<?php } ?>
<style>
.productbox div {
    text-align: center;
}
    .what-we-do .service { border-bottom: 2px solid <?php echo $settings->dark_color; ?> }
</style>
<?php }
include('includes/footer.php');

What can be the issue and it could be fixed?

Thanks in advance!

Sheryl
  • 9
  • 1
  • 3

1 Answers1

0
Information that was incorrect was fixed in the code below if it still does not work then please give all the code to correctly see which line is actually throwing an error


<div class="testimonials container">
            <div class="testimonials-title">
                <h3>Testimonials</h3>
            </div>
            <div class="row">
                <div class="tab-content">
                    <?php 
                        for($i = 1; $i <= $settings->total_testi; $i++) {
                            echo '
                                <div class="testimonial-list">
                                    <img src="admin/data/images/'.$data->testi_img->$i.'" title="" alt="">
                                    <p>'.stripslashes($data->testi_msg->$i).'<br><span class="violet" style="color: '.$settings->dark_color.';">'.$data->testi_auth->$i.'</span></p>
                                </div>
                            ';
                        }
                    ?>
                </div>
            </div>
        </div>

had a random <?php } ?> not sure what this is closing but it was not put in the giving source.

<style>
    .productbox div {
        text-align: center;
    }
        .what-we-do .service { border-bottom: 2px solid <?php echo $settings->dark_color; ?> }
    </style>
    <?php
    include('includes/footer.php');
    ?>
Jacob Webb
  • 84
  • 1
  • 8
  • the closing/end tag `?>` is not required - http://stackoverflow.com/questions/4410704/why-would-one-omit-the-close-tag or http://stackoverflow.com/questions/19953483/php-end-tag – Sean Jan 14 '17 at 05:46
  • Thanks didn't know that will fix :) – Jacob Webb Jan 14 '17 at 05:48
  • Thanks for looking into this @JacobWebb. I tried it but it didn't worked sadly. Also, I am surprised how its working on the online server but not on localhost. I will try to attach complete file! – Sheryl Jan 14 '17 at 06:49
  • @JacobWebb I added complete code, please see if you can help! – Sheryl Jan 14 '17 at 06:53
  • @Sheryl So looking at your code I notice you use ?> sure it's fine to end the file with no ?> but to start the block with something called short_open_tag could be off on your local server and turned on in the production server. To turn this setting check your PHP conf and find short_open_tag and make sure it says on – Jacob Webb Jan 14 '17 at 08:06
  • @JacobWebb Thanks for looking into this :) – Sheryl Jan 14 '17 at 14:53