Porkie Posted June 30, 2009 Share Posted June 30, 2009 $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 />'; then i want to echo this line, echo '<a href="http://www.asdad.co.uk/Newdirectory/video.php?id='.$row['id'].'" target="_blank"<img src="http://img.youtube.com/vi/'.$row['videoid'].'/default.jpg"width="120" height="100"/>'; however when i do , nothing is displayed, do i need to add videoid to line 1 , (the array) or is there somethign else i need to do? also i only want it to display the pictures for the video names displayed Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/ Share on other sites More sharing options...
Maq Posted June 30, 2009 Share Posted June 30, 2009 1) Use double quotes for the echoing string so your variables can interpolate. 2) Use single quotes for attributes. 3) You didn't close the 'a' tag with '>'. 4) You can use curly brackets to escape associative arrays. Not tested: echo ""; Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866387 Share on other sites More sharing options...
Porkie Posted June 30, 2009 Author Share Posted June 30, 2009 still doesnt load anything , can i pm you the whole code? cheers for the help Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866394 Share on other sites More sharing options...
Maq Posted June 30, 2009 Share Posted June 30, 2009 still doesnt load anything , can i pm you the whole code? No. Usually when the page is blank there is a fatal error. Try turning error reporting on by adding this code directly after your first opening <?php tag: ini_set ("display_errors", "1"); error_reporting(E_ALL); Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866396 Share on other sites More sharing options...
Porkie Posted June 30, 2009 Author Share Posted June 30, 2009 Notice: Undefined variable: row in /home/as/public_html/Newdirectory/video.php on line 205 Line 205 echo "<a href='http://www.sdsa.co.uk/Newdirectory/video.php?id={$row['id']}' target='_blank'><img src='http://img.youtube.com/vi/{$row['videoid']}/default.jpg' width='120' height='100'/>"; Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866408 Share on other sites More sharing options...
Maq Posted June 30, 2009 Share Posted June 30, 2009 Can you post the code before this that extracts the data from the database? Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866410 Share on other sites More sharing options...
Porkie Posted June 30, 2009 Author Share Posted June 30, 2009 thats the whole code mate , wasnt sure which bit you wanted cheers <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); 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>Name:</h2>'; echo stripslashes($video['name']); 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 />'; echo '<h2>More Videos You May Enjoy:</h2>'; include ('videofilm.php'); echo '<hr />'; 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 "<a href='http://www.sda.co.uk/Newdirectory/video.php?id={$row['id']}' target='_blank'><img src='http://img.youtube.com/vi/{$row['videoid']}/default.jpg' width='120' height='100'/>"; } } echo page_footer(); ?> Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866416 Share on other sites More sharing options...
Maq Posted June 30, 2009 Share Posted June 30, 2009 Where is the $sql object coming from that's making the SQL method calls? $videos = $sql->getData(true); Instead of $row you're supposed to be using $video, no? Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866425 Share on other sites More sharing options...
Porkie Posted June 30, 2009 Author Share Posted June 30, 2009 i dont get you i have a file called sql.class that what your after ? sorry about not really understanding i changed row to video and still same error cheers Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866441 Share on other sites More sharing options...
Maq Posted June 30, 2009 Share Posted June 30, 2009 My understanding is this. $videos = $sql->getData(true); This returns all the rows from the query call. echo ''.$videos[$c]['name'].' '; Here you're using the $video array that was returned from the getData() method. echo ""; Then you use a $row array that's not defined anywhere in your code. That's where the error is coming from. Did you change $row to $video in both places? Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866447 Share on other sites More sharing options...
Porkie Posted June 30, 2009 Author Share Posted June 30, 2009 yeh i have thanks Notice: Undefined index: id in /home/aa/public_html/Newdirectory/video.php on line 205 Notice: Undefined index: videoid in /home/aa/public_html/Newdirectory/video.php on line 205 i dont get how these are undefined :S help please cheers for reply Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866457 Share on other sites More sharing options...
Maq Posted June 30, 2009 Share Posted June 30, 2009 Try these: $videos[$c]['id'] and $videos[$c]['videoid'] Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866464 Share on other sites More sharing options...
Porkie Posted June 30, 2009 Author Share Posted June 30, 2009 cheers mate it worked , thanks alot can you just see whether you can work this out? Fatal error: Call to a member function select() on a non-object in /home/aa/public_html/Newdirectory/video.php on line 106 $sql->select(array('name','content','time'),'video_comment',array('time'),array('videoid:'.$_GET['id'])); Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866472 Share on other sites More sharing options...
Porkie Posted June 30, 2009 Author Share Posted June 30, 2009 can any1 find a solution to help me with the error above? cheers Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866727 Share on other sites More sharing options...
Maq Posted June 30, 2009 Share Posted June 30, 2009 Try creating an object then invoke the method. $sql2 = new className(); $sql2->select(array('name','id'),'video',$sort,array('active:1',$extra)); Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866733 Share on other sites More sharing options...
Porkie Posted June 30, 2009 Author Share Posted June 30, 2009 sorry mate nice one for all your help , where would i put that code? and can you explain abit more what you want me to do? sorry Link to comment https://forums.phpfreaks.com/topic/164241-confused-with-adding-and-extra-line/#findComment-866735 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.