Ben
Ben

Reputation: 3

Remove unknown text appearing on page

I have used a widget called addthisevent to allow users to add a class booking to their calendar. It is all working as indented but when I echo the link to the page I get a random ‘1’ next to the button. As you can see here -- http://oi60.tinypic.com/10fu8ac.jpg --

==add_event.php==

<?php

//Call session variables
$start_time = $_SESSION['class_time_start'];
$end_time = $_SESSION['class_time_end'];
$date = $_SESSION['class_date'];
$class_name = $_SESSION['class_name'];
$client_F_name = $_SESSION['firstname'];
$client_L_name = $_SESSION['lastname'];
$client_email = $_SESSION['email'];

//echo addthisevent script
echo '<script type="text/javascript" src="https://addthisevent.com/libs/ate-latest.min.js"></script>';

//echo addthisevent with the variables in place, ready to be converted using the JS function
echo '<a href="http://example.com/link-to-your-event" title="Add to Calendar" class="  addthisevent" id="addthisevent">'
, 'Add to Calendar'
, '<span class="_start">' . $date . ' ' . $start_time . '</span>'
, '<span class="_end">' . $date . ' ' . $end_time . '</span>'
, '<span class="_zonecode">36</span>'
, '<span class="_summary">' . $class_name . ' Class</span>'
, '<span class="_description">Your ' . $class_name . ' class with ****</span>'
, '<span class="_location">*****</span>'
, '<span class="_organizer">*****</span>'
, '<span class="_organizer_email">******</span>'
, '<span class="_facebook_event">*****</span>'
, '<span class="_all_day_event">false</span>'
, '<span class="_date_format">YYYY/MM/DD</span>'
, '</a>';
?>

Let me know if you need more code as I understand this is a weird issue I'm having.

I really can't work out what is causing it. I know it is definitely coming from the php above. If there is a way to fix this issue or just to simply remove the '1' after the page has loaded as a workaround that would be great

Thanks

The page link is http://217.37.5.115/content/temppage.php

you will need to select the dropdown boxes for it to appear

In short:

I use this function below to run a php script when the value of one of the dropdown boxes changes

===temppage.php (main page)===

<script>
    function class_space_Update(str) {
        if (str == "") {
            document.getElementById("class_spaces").innerHTML = "";
            return;
        } else {
            if (window.XMLHttpRequest) {
            //code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
            } else {
            //code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                    document.getElementById("class_spaces").innerHTML = xmlhttp.responseText;
                    addthisevent.refresh();                                                
                }
            }

            xmlhttp.open("GET", "../includes/get/class_spaces.php?id=" + str, true);
            xmlhttp.send();

        }
    }
</script>

===class_spaces.php===

<?php
//Set session variables
//Session 'class_time_start'
$_SESSION['class_time_start'] = $start_time;

//Session 'class_time_end'
$_SESSION['class_time_end'] = $end_time;

//Session 'class_date'
$_SESSION['class_date'] = $date;

//Session 'space_left'
$_SESSION['space_left'] = $space_left;

//Include add_event.php
echo include_once ($_SERVER["DOCUMENT_ROOT"] . "/includes/add_event.php");

//Close MySQLi connection
mysqli_close($mysqli);
?>

This isn't all of that file as it isn't really necessary.

If I comment out the echo include_once add_event.php part then the '1' does not appear.

Upvotes: 0

Views: 272

Answers (1)

Alex
Alex

Reputation: 17289

Quick solution I can offer for you is:

<?php

//Call session variables
$start_time = (isset($_SESSION['class_time_start']))?$_SESSION['class_time_start']:'';
$end_time = (isset($_SESSION['class_time_end']))?$_SESSION['class_time_end']:'';
$date = (isset($_SESSION['class_date']))?$_SESSION['class_date']:'';
$class_name = (isset($_SESSION['class_name']))?$_SESSION['class_name']:'';
$client_F_name = (isset($_SESSION['firstname']))?$_SESSION['firstname']:'';
$client_L_name = (isset($_SESSION['lastname']))?$_SESSION['lastname']:'';
$client_email = (isset($_SESSION['email']))?$_SESSION['email']:'';

//echo addthisevent script
ob_start();
echo '<script type="text/javascript" src="https://addthisevent.com/libs/ate-latest.min.js"></script>';

//echo addthisevent with the variables in place, ready to be converted using the JS function
echo '<a href="http://example.com/link-to-your-event" title="Add to Calendar" class="  addthisevent" id="addthisevent">'
, 'Add to Calendar'
, '<span class="_start">' . $date . ' ' . $start_time . '</span>'
, '<span class="_end">' . $date . ' ' . $end_time . '</span>'
, '<span class="_zonecode">36</span>'
, '<span class="_summary">' . $class_name . ' Class</span>'
, '<span class="_description">Your ' . $class_name . ' class with ****</span>'
, '<span class="_location">*****</span>'
, '<span class="_organizer">*****</span>'
, '<span class="_organizer_email">******</span>'
, '<span class="_facebook_event">*****</span>'
, '<span class="_all_day_event">false</span>'
, '<span class="_date_format">YYYY/MM/DD</span>'
, '</a>';
exit();

Upvotes: 1

Related Questions