Parse error: syntax error, unexpected $end

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
breWtal
Forum Newbie
Posts: 8
Joined: Tue Jun 16, 2009 2:55 am

Parse error: syntax error, unexpected $end

Post by breWtal »

when running the script, the required page opens, but now im getting a different error message.

now the problem has been fixed in the config script im getting an error in the mail.php file

Parse error: syntax error, unexpected $end in /homepages/46/d285340853/htdocs/sms/SMS.Script.v2.1/mail.php on line 47

<?
session_start();
session_register('sessioncode');
?>

<?
include("config.php");
?>

<?
if (strtoupper($code) == substr(strtoupper(md5("Mytext".$sessioncode)), 0,6)) {
} else {
?>
CAPTCHA WRONG!<br>
Click <a href="sms.php">HERE</a> to return.

<?
$day = date("mdy");
$ip = GetHostByName($REMOTE_ADDR);
$checkuses=mysql_num_rows(mysql_query("select * from users where ip='$ip' and day='$day'"));
if($checkuses >= $alloweduses) {
echo "Your limit has been reached for today.";
exit;
} else {
$query = "INSERT INTO users VALUES ('$ip','$number','$day')";
$result = mysql_query($query) or die("Unable to add IP address");
}
?>

<?
$sql = "SELECT * FROM carriers WHERE id = '$carrier'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$email = $row["email"];
$to = $number . $email;
$headers = $headerstouse;
$message = $headeradvertisement.$message.$footeradvertisement;
mail ($to, $from, $subject, $message, $headers);
?>

<? echo "Message Sent!<br><br>";
echo "to: ".$to."<br>";
echo "from: ".$from."<br>";
echo "subject: ".$subject."<br>";
echo "message: ".$message."<br><br>";
echo "headers: ".$headers."<br><br>";
echo "Click <a href=\"".$_SERVER['HTTP_REFERER']."\">HERE</a>, to send SMS."?>


sorry, that im asking for a lot of help
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Parse error: syntax error, unexpected $end

Post by Mark Baker »

Generally this error means that you're missing a closing bracket { in your code

Learn to indent your code, it makes this type of error a lot easier to identify

You should be able to see why you're getting the error if you look at the indented version of your code:

Code: Select all

 
<?
session_start();
session_register('sessioncode');
?>
 
<?
include("config.php");
?>
 
<?
if (strtoupper($code) == substr(strtoupper(md5("Mytext".$sessioncode)), 0,6)) {
} else {
?>
    CAPTCHA WRONG!<br>
    Click <a href="sms.php">HERE</a> to return.
 
    <?
    $day = date("mdy");
    $ip = GetHostByName($REMOTE_ADDR);
    $checkuses=mysql_num_rows(mysql_query("select * from users where ip='$ip' and day='$day'"));
    if($checkuses >= $alloweduses) {
        echo "Your limit has been reached for today.";
        exit;
    } else {
        $query = "INSERT INTO users VALUES ('$ip','$number','$day')";
        $result = mysql_query($query) or die("Unable to add IP address");
    }
    ?>
 
    <?
    $sql = "SELECT * FROM carriers WHERE id = '$carrier'";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    $email = $row["email"];
    $to = $number . $email;
    $headers = $headerstouse;
    $message = $headeradvertisement.$message.$footeradvertisement;
    mail ($to, $from, $subject, $message, $headers);
    ?>
 
    <? echo "Message Sent!<br><br>";
    echo "to: ".$to."<br>";
    echo "from: ".$from."<br>";
    echo "subject: ".$subject."<br>";
    echo "message: ".$message."<br><br>";
    echo "headers: ".$headers."<br><br>";
    echo "Click <a href=\"".$_SERVER['HTTP_REFERER']."\">HERE</a>, to send SMS."?>
 
P.S.
Start using long php opening tags <?php rather than the deprecated <?
And there's no need to keep dropping in and out of PHP, this could actually cause you problems sending white space output to the browser when you don't want it to
Post Reply