Jump to content

Parse error: parse error, unexpected $ in....


shareen

Recommended Posts

Hi, i am new here.
I am having an issue with PHP. Its giving me a really annoying error and i can't figure out why.

The error:
[b]Parse error: parse error, unexpected $ in /home/stud/1/c0261087/public_html/blog/process2.php on line 99[/b]
Can someone see something i can't?


[code]<?php

include "./db_lib.inc";
$link_id = db_connect();

$postId = $_Post['id'];
    
        $sqlquery = "SELECT date FROM $locking_tablename where [id] = $postId ";
        $result = mysql_query($sqlquery);
        
while($row = @mysql_fetch_array($result))
{
$starttime = $row['date'];
$endtime = date("d-m-y G.i");
}



if ($diff = @get_time_difference($starttime,$endtime))
{
echo "Minutes" . sprintf( '%02d',$diff['minutes'] );
}


if ($_POST['text'] == '' || $_POST['author'] == '' ) {
echo "Please fill out all elements.";
echo "<a href=\"comment.php?Name=$DisplayName\">Back</a>";
die();
{



    

    $text = $_POST['text'];
    $author = $_POST['author'];
    
    $title = $_POST['title'];

    $date = date("d-m-y G.i");
    
    
            
        $query = "INSERT INTO $locking_tablename (`title` , `author` , `date` , `entry`)
        VALUES ('$title', '$author', '$date', '$text')";

        $result = mysql_query($query);

        if (!$result) {
              error_message(sql_error());
            } else {

            echo "Post successful!<br />";
            echo "Your Comment ". $text . ". <br />";
            echo "Author:" . $author . ".<br />";
            echo "To log out <a href='logout.php'>click here</a><br />";
            echo "To Post a new comment <a href='comment.php'>click here</a>";
        
}

}


function get_time_difference( $start, $end )
{
    $uts['start']      =    strtotime( $start );
    $uts['end']        =    strtotime( $end );
    if( $uts['start']!==-1 && $uts['end']!==-1 )
    {
        if( $uts['end'] >= $uts['start'] )
        {
            $diff    =    $uts['end'] - $uts['start'];
            if( $days=intval((floor($diff/86400))) )
                $diff = $diff % 86400;
            if( $hours=intval((floor($diff/3600))) )
                $diff = $diff % 3600;
            if( $minutes=intval((floor($diff/60))) )
                $diff = $diff % 60;
            $diff    =    intval( $diff );            
            return( array('days'=>$days, 'hours'=>$hours, 'minutes'=>$minutes, 'seconds'=>$diff) );
        }
        else
        {
            trigger_error( "Ending date/time is earlier than the start date/time", E_USER_WARNING );
        }
    }
    else
    {
        trigger_error( "Invalid date/time data detected", E_USER_WARNING );
    }
    return( false );



?>[/code]
Link to comment
Share on other sites

Hey,
i'm kind of new to php.

This page looks really interesting and exactly what i need for the wiki i am creating.

However, i don't know how to adapt the code to say

Do i just say

[code]if ($diff = @get_time_difference($starttime,$endtime))
{
if $diff < 7
{
header(location etc
}
}[/code]

The problem is how to adapt this little bit into there so i can pick up the seconds.
Can someone help, would this work for seconds?

[code]sprintf( '%02d',$diff['seconds'] );[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.