Page 1 of 1

Having trouble with part 04 of blog tutorial

Posted: Sun Jan 29, 2012 11:16 pm
by hellboj
i stuck here when i run that file...
 <?php
 
 	include('core/init.inc.php');
 
 ?>
 
  
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 	<head>
 		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset="windows-1250">
 		<title>Polna Pljuca Blog</title>
 	</head>
 	<body>
 			<div>
 				<?php
 				
 					$posts = get_posts();
 					
 				/*		print_r($posts);*/
 					
 				foreach ($posts as $post){
 				?>
 			<h2><?php echo $post['title'];  ?></h2>
 			<h4>By <?php echo $post['user']; ?> on <?php echo ['date']; ?></h4>
 			<h4><?php echo $post['total_comments']; ?> comments, last comment <?php echo ['last_comment']; ?></h4>
 			
 			<hr />
 			
 			<p><?php echo $post['preview']; ?></p>
 			
 			<?php
 			
 			}   
 			
 			?>
 			</div>
 	</body>
 </html>
i get that Parse error: syntax error, unexpected '[' in /Applications/XAMPP/xamppfiles/htdocs/blog/blog_list.php on line 25


and if i use like this:
 <?php
 
 	include('core/init.inc.php');
 
 ?>
 
  
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 	<head>
 		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset="windows-1250">
 		<title>Polna Pljuca Blog</title>
 	</head>
 	<body>
 			<div>
 				<?php
 				
 					$posts = get_posts();
 					
 					print_r($posts);
 					
 				/*foreach ($posts as $post){
 				?>
 			<h2><?php echo $post['title'];  ?></h2>
 			<h4>By <?php echo $post['user']; ?> on <?php echo ['date']; ?></h4>
 			<h4><?php echo $post['total_comments']; ?> comments, last comment <?php echo ['last_comment']; ?></h4>
 			
 			<hr />
 			
 			<p><?php echo $post['preview']; ?></p>
 			
 			<?php
 			
 			}   */
 			
 			?>
 			</div>
 	</body>
 </html>

i get this error Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/blog/core/inc/posts.inc.php on line 48

won't stop reloading the page.

can you help me pleas....

Re: Having trouble with part 04 of blog tutorial

Posted: Sun Jan 29, 2012 11:28 pm
by hellboj
i fix code in blog_list.php
 <?php
 
 	include('core/init.inc.php');
 
 ?>
 
  
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 	<head>
 		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset="windows-1250">
 		<title>Polna Pljuca Blog</title>
 	</head>
 	<body>
 			<div>
 				<?php
 				
 					$posts = get_posts();
 					
 				/*	print_r($posts);*/
 					
 					foreach ($posts as $post){
 				?>
 			<h2><?php echo $post['title'];  ?></h2>
 			<h4>By <?php echo $post['user'];  ?> on <?php echo $post['date'];  ?></h4>
 			<h4>(<?php echo $post['total_commensts'];  ?> comments, last comment <?php echo $post['last_comment'];  ?>)</h4>
 			
 			<hr />
 			
 			<p><?php echo $post['preview']; ?></p>
 			
 			<?php
 			
 			}   
 			
 			?>
 			</div>
 	</body>
 </html>
and i get error------> Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/blog/core/inc/posts.inc.php on line 48

what that mean can pleas,pleas help me... i'M not good in php. :S

Re: Having trouble with part 04 of blog tutorial

Posted: Sun Jan 29, 2012 11:37 pm
by hellboj

Re: Having trouble with part 04 of blog tutorial

Posted: Tue Jan 31, 2012 7:27 pm
by jacek
hellboj wrote:sorry i find here http://betterphp.co.uk/board/viewtopic. ... 6987#p6998

tnx .... ;)
I love topics that solve themselves :)