shareen Posted April 26, 2006 Share Posted April 26, 2006 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]<?phpinclude "./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] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 26, 2006 Share Posted April 26, 2006 You're missing the final closing curly brace in the last function.Ken Quote Link to comment Share on other sites More sharing options...
snips Posted April 27, 2006 Share Posted April 27, 2006 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 sayDo 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.