Jump to content

Recommended Posts

$sql->select(array('name','content','time'),'video_comment',array('time'),array('videoid:'.$_GET['id']));
$comments = $sql->getData(true);
if ($comments['_total'] > 0) {
	echo '<h1>Comments</h1>';
	for ($c = 0; $c < $comments['_total']; ++$c) {
		echo '<b>'.stripslashes($comments[$c]['name']).' said:</b> ('.$time->difference($comments[$c]['time']).')<br />';
		echo stripslashes($comments[$c]['content']);
		echo '<hr />';
	}
}

 

 

Fatal error: Call to a member function difference() on a non-object in /home/df/public_html/Newdirectory/video.php on line 108

 

On Line :

echo '<b>'.stripslashes($comments[$c]['name']).' said:</b> ('.$time->difference($comments[$c]['time']).')<br />';

 

im very confused =( help?

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/164017-fatal-php-error/
Share on other sites

Change:

$f = new form;
$sql = new sql($sql[0],$sql[1],$sql[2],$sql[3],$sql[4]);
$time = new time();

 

To:

$f = new form;
$sql = new sql($sql[0],$sql[1],$sql[2],$sql[3],$sql[4]);
$time = new time();
echo '<pre>'; print_r($time); print_r(get_class_methods('time')); echo '</pre>';

 

What does that output? I think you may be having problems with the name of your class (time) since there is also a built-in function with the name 'time'. Just a hunch.

 

EDIT: updated some code, sorry.

Link to comment
https://forums.phpfreaks.com/topic/164017-fatal-php-error/#findComment-865251
Share on other sites

time Object
(
    [stamp] => 2009-06-28-20-07-25
    [stampArray] => Array
        (
            [0] => 2009
            [1] => 06
            [2] => 28
            [3] => 20
            [4] => 07
            [5] => 25
        )

)
Array
(
    [0] => __construct
    [1] => seconds
    [2] => difference
    [3] => getDifference
)

 

 

i  get that at the top of my page now ?

 

cheers

Link to comment
https://forums.phpfreaks.com/topic/164017-fatal-php-error/#findComment-865260
Share on other sites

At anytime between when you create your objects and the time you get here:

echo '<b>'.stripslashes($comments[$c]['name']).' said:</b> ('.$time->difference($comments[$c]['time']).')<br />';

 

Do you have another $time variable? You might need to post your whole code, since nothing is popping out at me right now.

Link to comment
https://forums.phpfreaks.com/topic/164017-fatal-php-error/#findComment-865263
Share on other sites

<?php
require('core.inc.php');

if (isset($_GET['id'])) {
$sql->select(array('name','description','videoid','tags','category','id','time'),'video','time',array('active:1'));
$vid = $sql->getData(true);
$vid_list = array();
for ($c = 0; $c < $vid['_total']; ++$c) {
	array_push($vid_list,$vid[$c]['id']);
}
if (!in_array($_GET['id'],$vid_list)) {
	header('Location: index.php');	
}
}

echo page_header('Videos');

?><script>function updateScore(vaa) {
var total = document.getElementById('ratingtop_total').value;
    var users = document.getElementById('ratingtop_users').value;
    users++;
    total = ((total*1)+(vaa*1));
    var finalscore = (total/users);
    finalscore = Math.round(finalscore);
    document.getElementById('rating_dyn').innerHTML = '<b>' + users + '</b>';
toggleRating(finalscore,false,true);
}

howmany = 3;
function toggleRating(amt,stay,rate2) {
    if (stay) {
        amt = howmany;
    }
    if (rate2) {
    	var rater = 'toprate';
    }
    else {
    	var rater = 'rate';
    }
    var img1 = 'img/star_on.png';
    var img2 = 'img/star_off.png';
    for (var c=0;c<amt;++c) {
        document.getElementById(rater+(c+1)).src = img1;
    }
    for (var c=amt;c<5;++c) {
        document.getElementById(rater+(c+1)).src = img2;
    }
    if (!rate2) {
    document.getElementById('input_rating_input').value = amt;
    }
}
function setRating(amt) {
    howmany = amt;
}</script><?php
include ('Check.php');
if (isset($_GET['id'])) {
$sql->select(array('name','description','videoid','tags','category','time'),'video','',array('id:'.$_GET['id']));
$video = $sql->getData();
print ("<table>");
    print ("<tr>");
    print ("<td>");
echo '<h1>'.stripslashes(ucfirst($video['category'])).' \\ '.stripslashes(ucfirst($video['name'])).'</h1>';
print ("</td>");
print ("</tr>");
print ("<tr>");
    print ("<td>");
    echo '<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/'.$video['videoid'].'&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'.$video['videoid'].'&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>';
    print ("</td>");
    print ("<td align='left' valign='top'>");
echo '<hr />';
    echo '<h2>Description</h2>';
echo stripslashes($video['description']);
echo '<hr />';
echo '<h2>Tags</h2>';
echo stripslashes($video['tags']);
echo '<hr />';
echo '<h2>Category</h2>';
echo stripslashes($video['category']);
echo '<hr />';
echo '<h2>Current Rating</h2>';
$sql->select(array('vote_total','vote_count'),'video','',array('id:'.$_GET['id']));
$votes = $sql->getData();
$amt = round($votes['vote_total'] / $votes['vote_count']);
'Current Rating: ';
for ($c = 0; $c < 5; ++$c) {
	echo '<img src="img/star_'.($c < $amt?'on':'off').'.png" />';
}
echo '<hr />';
include ('Tags.php');
    print ("</td>");
    print ("</tr>");
    print ("</table>");







$sql->select(array('name','content','time'),'video_comment',array('time'),array('videoid:'.$_GET['id']));
$comments = $sql->getData(true);
if ($comments['_total'] > 0) {
	echo '<h1>Comments</h1>';
	for ($c = 0; $c < $comments['_total']; ++$c) {
		echo '<b>'.stripslashes($comments[$c]['name']).' said:</b> ('.$time->difference($comments[$c]['time']).')<br />';
		echo stripslashes($comments[$c]['content']);
		echo '<hr />';
	}
}
print ("<table>");
    print ("<tr>");
    print ("<td>");
echo '<h1>Add your own comment</h1>';
print ("</tr>");
    print ("</td>");
echo $f->open('addComment');
echo $f->hidden('id',$_GET['id']);
print ("<tr>");
    print ("<td>");
echo 'Name:'
print ("</td>");
print ("<td>");
echo $f->text('name').'<br />';
print ("</td>");
print ("</tr>");
print ("<tr>");
    print ("<td>");
echo 'Comment:'
print ("</td>");
print ("<td>");
    echo $f->textarea('comment');
    print ("</td>");
print ("</tr>");
print ("<tr>");
print ("<td>");
echo $f->submit();
print ("</td>");
print ("</tr>");
echo $f->close();

echo '<hr />';

$sql->select(array('ip'),'video_comment_log','',array('videoid:'.$_GET['id']));
$ip = $sql->getData(true);
$ips = array();
for ($c = 0; $c < $ip['_total']; ++$c) {
	array_push($ips,$ip[$c]['ip']);
}

if (!in_array($_SERVER['REMOTE_ADDR'],$ips)) {
	echo '<div id="stars">';
	for ($c=1;$c<=5;++$c) {
		echo '<img alt="" onmouseout="toggleRating(false,true);return true;" onclick="setRating('.$c.');return true;" id="rate'.$c.'" onmouseover="toggleRating('.$c.');return true;" src="img/star_'.($c<=3?'on':'off').'.png" />';
	}
	echo '</div>';
	echo $f->open('videoVote').$f->hidden('id',$_GET['id']).$f->hidden('rating_input','3').$f->submit().$f->close();
}
}

else {

$extra = '?';
if (isset($_GET['category'])) {
	$extra = '?category='.$_GET['category'].'&';
}
echo 'Sort By: <a href="video.php'.$extra.'">All</a> - <a '.(isset($_GET['sort']) ? '' : 'style="color:white;"') .' href="video.php'.$extra.'sort">Name</a> - <a '.(isset($_GET['sort']) ? 'style="color:white;"' : '') .' href="video.php'.$extra.'">Latest</a>';
echo '<hr />';

$extra = '?';
if (isset($_GET['sort'])) {
	$extra = '?sort&';
}
echo 'Sort Category: ';
$sql->select(array('category'),'video','',array('active:1'),true);
$all = $sql->getData(true);
$cat = array();
for ($c = 0; $c < $all['_total']; ++$c) {
	array_push($cat,$all[$c]['category']);	
}
echo '  <a href="video.php'.$extra.'">All</a>';
foreach ($cat as $val) {
	echo '  <a href="video.php'.$extra.'category='.$val.'">'.ucfirst($val).'</a>';	
}
echo '<hr />';


$extra = '';
if (isset($_GET['category'])) {
	$extra = 'category:'.$_GET['category'];	
}
$sort = 'time';
if (isset($_GET['sort'])) {
	$sort = 'name';
}
$sql->select(array('name','id'),'video',$sort,array('active:1',$extra));
$videos = $sql->getData(true);
for ($c = 0; $c < $videos['_total']; ++$c) {
		echo '<a style="color:white;" href="video.php?id='.$videos[$c]['id'].'">'.$videos[$c]['name'].'</a><br />';
}	
}


echo page_footer();

?>

Link to comment
https://forums.phpfreaks.com/topic/164017-fatal-php-error/#findComment-865648
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.