Jump to content


Photo

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


  • Please log in to reply
2 replies to this topic

#1 shareen

shareen
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 26 April 2006 - 06:51 PM

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:
Parse error: parse error, unexpected $ in /home/stud/1/c0261087/public_html/blog/process2.php on line 99
Can someone see something i can't?


<?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 );



?>


#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 26 April 2006 - 06:55 PM

You're missing the final closing curly brace in the last function.

Ken

#3 snips

snips
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 27 April 2006 - 07:39 AM

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

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

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?

sprintf( '%02d',$diff['seconds'] );





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users