blog tutorial need help/part05

Ask about a PHP problem here.
Post Reply
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

blog tutorial need help/part05

Post by hellboj »

after i do the page blog_list.php a i go and test the page i get this warning:

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/blog/core/inc/comments.inc.php on line 17
<?php

		//puščaš vse objave ki so dane v blogu.
		function get_comments($pid) {
			$pid = (int)$pid;
			
			$sql = "SELECT
					`comment_body` AS `body`,
					`comment_user` AS `user`,
					DATE_FORMAT(`comment_date`, '%d/%m/%Y %H:%i:%s') AS `date`
					FROM `comments`
					WHERE `post_id` = {pid}";
		
			$comments = mysql_query($sql);
			
			$return = array();
			while (($row =mysql_fetch_assoc($comments)) !== false) {
				$return[] = $row;
			}
			return $return;
		}

		//dodaj komentar
		function add_comments($pid, $user, $body) {
		if (valid_pid($pid) === fales) {
			return false;
		}
			$pid   = (int)$pid;
			$user  = mysql_real_escape_string(htmlentites($user));
			$body  = mysql_real_escape_string(nl2br(htmlentites($body)));
			
			mysql_query("INSERT INTO `comments` (`post_id`, `comment_user`, `comment_body`, `comment_date`) VALUES ({$pid}, '{$user}', '{$body}', NOW())");
			
			return true;
		}
?>
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: blog tutorial need help/part05

Post by Temor »

you missed a $ before the $pid variable in your sql query.
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

Re: blog tutorial need help/part05

Post by hellboj »

Temor wrote:you missed a $ before the $pid variable in your sql query.
Thank you 1000 times... :oops:
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

Re: blog tutorial need help/part05

Post by hellboj »

hellboj wrote:
Temor wrote:you missed a $ before the $pid variable in your sql query.
Thank you 1000 times... :oops:

what i missed here? i really suks... not my days--- :? :cry:
<?php
 			
 				foreach ($post['comments'] as comment) {
 			?>
 				<h4>Od<?php echo $comment['user']; ?> ustvarjeno <?php echo $comment['date']; ?></h4>
 				<p><?php echo $comment['body']; ?></p>
 				<hr />
 			<?php
 			}
 			
 			?>
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

Re: blog tutorial need help/part05

Post by hellboj »

hellboj wrote:
hellboj wrote:
Temor wrote:you missed a $ before the $pid variable in your sql query.
Thank you 1000 times... :oops:

what i missed here? i really suks... not my days--- :? :cry:
<?php
 			
 				foreach ($post['comments'] as comment) {
 			?>
 				<h4>Od<?php echo $comment['user']; ?> ustvarjeno <?php echo $comment['date']; ?></h4>
 				<p><?php echo $comment['body']; ?></p>
 				<hr />
 			<?php
 			}
 			
 			?>
i get error:

Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM in /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php on line 39
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

Re: blog tutorial need help/part05

Post by hellboj »

hellboj wrote:
hellboj wrote:
hellboj wrote: Thank you 1000 times... :oops:

what i missed here? i really suks... not my days--- :? :cry:
<?php
 			
 				foreach ($post['comments'] as comment) {
 			?>
 				<h4>Od<?php echo $comment['user']; ?> ustvarjeno <?php echo $comment['date']; ?></h4>
 				<p><?php echo $comment['body']; ?></p>
 				<hr />
 			<?php
 			}
 			
 			?>
i get error:

Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM in /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php on line 39


uuuu sory finly saw it i miss $ in comment...
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

blog tutorial need help/part06

Post by hellboj »

can you help me?

error:

Fatal error: Call to undefined function add_comment() in /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php on line 6

blog_read.php
 <?php
 
  <?php
 
 	include('core/init.inc.php');

		if (isset($_GET['pid'], $_POST['user'], $_POST['body'])){
			if (add_comment($_GET['pid'], $_POST['user'], $_POST['body'])){                       
				header("Location: blog_read.php?pid={$_GET['pid']}");
		}else{
				header('Location: blog_list.php');
		}
			die();
}
 ?>
 
 <!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">
 		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset="utf-8">
 		
 		<title>Polna Pljuca Blog</title>
 	</head>
 	<body>
 			<div align="center">
 				<h1>Zapiši idejo</h1>
 				<h2>let's word talks...</h2>
 			<?php
 			
 				if (isset($_GET['pid']) === false || valid_pid($_GET['pid']) === false){
 					echo 'Invalid post ID.';
 				}else{
 					$post = get_post($_GET['pid']);
 					
 			?>	
 				<h2><?php echo $post['title']; ?></h2>
 				<h4>Od <?php echo $post['user'];  ?> ob <?php echo $post['date']; ?> (<?php echo count($post['comments']); ?> comments)</h4>
 			
 			<hr />
 			
 			<p><?php echo $post['body'];   ?></p>
 				
 			<hr />
 			
 			<?php
 			
 				foreach ($post['comments'] as $comment) {
 			?>
 				<h4>Od<?php echo $comment['user']; ?> ustvarjeno <?php echo $comment['date']; ?></h4>
 				<p><?php echo $comment['body']; ?></p>
 				<hr />
 			<?php
 			}
 			
 			?>
 			<form action="" method="post">
 				<p>
 					<label for="user">Ime:</label>
 					<input type="text" name="user" id="user" />
 				</p>
 				<p>
 					<textarea name="body" rows="20" cols="60"></textarea>
 				</p>
 				<p>
 					<input type="submit" value="Dodaj komentar" />
 				</p>
 			
 			</form>
 		<?php
 		}
 		?>
 	</div>
 			
 	</body>
 </html>
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

Re: blog tutorial need help/part06

Post by hellboj »

hellboj wrote:can you help me?

error:

Fatal error: Call to undefined function add_comment() in /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php on line 6

blog_read.php
 <?php
 
  <?php
 
 	include('core/init.inc.php');

		if (isset($_GET['pid'], $_POST['user'], $_POST['body'])){
			if (add_comment($_GET['pid'], $_POST['user'], $_POST['body'])){                       
				header("Location: blog_read.php?pid={$_GET['pid']}");
		}else{
				header('Location: blog_list.php');
		}
			die();
}
 ?>
 
 <!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">
 		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset="utf-8">
 		
 		<title>Polna Pljuca Blog</title>
 	</head>
 	<body>
 			<div align="center">
 				<h1>Zapiši idejo</h1>
 				<h2>let's word talks...</h2>
 			<?php
 			
 				if (isset($_GET['pid']) === false || valid_pid($_GET['pid']) === false){
 					echo 'Invalid post ID.';
 				}else{
 					$post = get_post($_GET['pid']);
 					
 			?>	
 				<h2><?php echo $post['title']; ?></h2>
 				<h4>Od <?php echo $post['user'];  ?> ob <?php echo $post['date']; ?> (<?php echo count($post['comments']); ?> comments)</h4>
 			
 			<hr />
 			
 			<p><?php echo $post['body'];   ?></p>
 				
 			<hr />
 			
 			<?php
 			
 				foreach ($post['comments'] as $comment) {
 			?>
 				<h4>Od<?php echo $comment['user']; ?> ustvarjeno <?php echo $comment['date']; ?></h4>
 				<p><?php echo $comment['body']; ?></p>
 				<hr />
 			<?php
 			}
 			
 			?>
 			<form action="" method="post">
 				<p>
 					<label for="user">Ime:</label>
 					<input type="text" name="user" id="user" />
 				</p>
 				<p>
 					<textarea name="body" rows="20" cols="60"></textarea>
 				</p>
 				<p>
 					<input type="submit" value="Dodaj komentar" />
 				</p>
 			
 			</form>
 		<?php
 		}
 		?>
 	</div>
 			
 	</body>
 </html>
may be is something wrong in comments.inc.php
<?php

		//puščaš vse objave ki so dane v blogu.
		function get_comments($pid){
			$pid = (int)$pid;
			
			$sql = "SELECT
					`comment_body` AS `body`,
					`comment_user` AS `user`,
					DATE_FORMAT(`comment_date`, '%d/%m/%Y %H:%i:%s') AS `date`
					FROM `comments`
					WHERE `post_id` = {$pid}";
		
			$comments = mysql_query($sql);
			
			$return = array();
			while (($row =mysql_fetch_assoc($comments)) !== false) {
				$return[] = $row;
			}
			return $return;
		}

		//dodaj komentar
		function add_comments($pid, $user, $body) {
		if (valid_pid($pid) === fales) {
			return false;
		}
			$pid   = (int)$pid;
			$user  = mysql_real_escape_string(htmlentities($user));
			$body  = mysql_real_escape_string(nl2br(htmlentities($body)));
			
			mysql_query("INSERT INTO `comments` (`post_id`, `comment_user`, `comment_body`, `comment_date`) VALUES ({$pid}, '{$user}', '{$body}', NOW())");
			
			return true;
		}
?>
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

Re: blog tutorial need help/part06

Post by hellboj »

hellboj wrote:
hellboj wrote:can you help me?

error:

Fatal error: Call to undefined function add_comment() in /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php on line 6

blog_read.php
 <?php
 
  <?php
 
 	include('core/init.inc.php');

		if (isset($_GET['pid'], $_POST['user'], $_POST['body'])){
			if (add_comment($_GET['pid'], $_POST['user'], $_POST['body'])){                       
				header("Location: blog_read.php?pid={$_GET['pid']}");
		}else{
				header('Location: blog_list.php');
		}
			die();
}
 ?>
 
 <!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">
 		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset="utf-8">
 		
 		<title>Polna Pljuca Blog</title>
 	</head>
 	<body>
 			<div align="center">
 				<h1>Zapiši idejo</h1>
 				<h2>let's word talks...</h2>
 			<?php
 			
 				if (isset($_GET['pid']) === false || valid_pid($_GET['pid']) === false){
 					echo 'Invalid post ID.';
 				}else{
 					$post = get_post($_GET['pid']);
 					
 			?>	
 				<h2><?php echo $post['title']; ?></h2>
 				<h4>Od <?php echo $post['user'];  ?> ob <?php echo $post['date']; ?> (<?php echo count($post['comments']); ?> comments)</h4>
 			
 			<hr />
 			
 			<p><?php echo $post['body'];   ?></p>
 				
 			<hr />
 			
 			<?php
 			
 				foreach ($post['comments'] as $comment) {
 			?>
 				<h4>Od<?php echo $comment['user']; ?> ustvarjeno <?php echo $comment['date']; ?></h4>
 				<p><?php echo $comment['body']; ?></p>
 				<hr />
 			<?php
 			}
 			
 			?>
 			<form action="" method="post">
 				<p>
 					<label for="user">Ime:</label>
 					<input type="text" name="user" id="user" />
 				</p>
 				<p>
 					<textarea name="body" rows="20" cols="60"></textarea>
 				</p>
 				<p>
 					<input type="submit" value="Dodaj komentar" />
 				</p>
 			
 			</form>
 		<?php
 		}
 		?>
 	</div>
 			
 	</body>
 </html>
may be is something wrong in comments.inc.php
<?php

		//puščaš vse objave ki so dane v blogu.
		function get_comments($pid){
			$pid = (int)$pid;
			
			$sql = "SELECT
					`comment_body` AS `body`,
					`comment_user` AS `user`,
					DATE_FORMAT(`comment_date`, '%d/%m/%Y %H:%i:%s') AS `date`
					FROM `comments`
					WHERE `post_id` = {$pid}";
		
			$comments = mysql_query($sql);
			
			$return = array();
			while (($row =mysql_fetch_assoc($comments)) !== false) {
				$return[] = $row;
			}
			return $return;
		}

		//dodaj komentar
		function add_comments($pid, $user, $body) {
		if (valid_pid($pid) === fales) {
			return false;
		}
			$pid   = (int)$pid;
			$user  = mysql_real_escape_string(htmlentities($user));
			$body  = mysql_real_escape_string(nl2br(htmlentities($body)));
			
			mysql_query("INSERT INTO `comments` (`post_id`, `comment_user`, `comment_body`, `comment_date`) VALUES ({$pid}, '{$user}', '{$body}', NOW())");
			
			return true;
		}
?>
i fix erorr
Fatal error: Call to undefined function add_comment() in /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php on line 6

and get new one
Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php:1) in /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php on line 7

i lost and don't now what to fix....help pleas :?
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: blog tutorial need help/part05

Post by Temor »

Fatal error: Call to undefined function add_comment() in /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php on line 6
That means you failed to include comments.inc.php. Are you including it in init.inc.php?
Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php:1) in /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php on line 7
 <?php
 
  <?php
 
this won't work. it doesn't make sense to open a new php block without closing the previous one.

Remove the second <?php tag and it should work.
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

Re: blog tutorial need help/part05

Post by hellboj »

this won't work. it doesn't make sense to open a new php block without closing the previous one.

Remove the second <?php tag and it should work.[/quote]

i remove <?php and still not working...
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

Re: blog tutorial need help/part05

Post by hellboj »

hellboj wrote:this won't work. it doesn't make sense to open a new php block without closing the previous one.

Remove the second <?php tag and it should work.
i remove <?php and still not working...[/quote]

the same error

Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php:1) in /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php on line 7
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

Re: blog tutorial need help/part05

Post by hellboj »

hellboj wrote:
hellboj wrote:this won't work. it doesn't make sense to open a new php block without closing the previous one.

Remove the second <?php tag and it should work.
i remove <?php and still not working...
the same error

Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php:1) in /Applications/XAMPP/xamppfiles/htdocs/blog/blog_read.php on line 7[/quote]

 <?php
 
 	include('core/init.inc.php');

		if (isset($_GET['pid'], $_POST['user'], $_POST['body'])){
			if (add_comments($_GET['pid'], $_POST['user'], $_POST['body'])){
				header("Location: blog_read.php?pid={$_GET['pid']}");
		}else{
				header('Location: blog_list.php');
		}
			die();
}
?>
 
 <!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">
 		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset="utf-8">
 		
 		<title>Polna Pljuca Blog</title>
 	</head>
 	<body>
 			<div align="center">
 				<h1>Zapiši idejo</h1>
 				<h2>let's word talks...</h2>
 			<?php
 			
 				if (isset($_GET['pid']) === false || valid_pid($_GET['pid']) === false){
 					echo 'Invalid post ID.';
 				}else{
 					$post = get_post($_GET['pid']);
 					
 			?>	
 				<h2><?php echo $post['title']; ?></h2>
 				<h4>Od <?php echo $post['user'];  ?> ob <?php echo $post['date']; ?> (<?php echo count($post['comments']); ?> comments)</h4>
 			
 			<hr />
 			
 			<p><?php echo $post['body'];   ?></p>
 				
 			<hr />
 			
 			<?php
 			
 				foreach ($post['comments'] as $comment) {
 			?>
 				<h4>Od<?php echo $comment['user']; ?> ustvarjeno <?php echo $comment['date']; ?></h4>
 				<p><?php echo $comment['body']; ?></p>
 				<hr />
 			<?php
 			}
 			
 			?>
 			<form action="" method="post">
 				<p>
 					<label for="user">Ime:</label>
 					<input type="text" name="user" id="user" />
 				</p>
 				<p>
 					<textarea name="body" rows="20" cols="60"></textarea>
 				</p>
 				<p>
 					<input type="submit" value="Dodaj komentar" />
 				</p>
 			
 			</form>
 		<?php
 		}
 		?>
 	</div>
 			
 	</body>
 </html>
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

Re: blog tutorial need help/part05

Post by hellboj »

and this is my
post.inc.php
<?php
		// preveri če je post id v tabli.
		function valid_pid($pid) {
		
			$pid = (int)$pid;
			
			$total = mysql_query("SELECT COUNT(`post_id`) FROM `posts` WHERE `post_id`  = {$pid}");
			$total = mysql_result($total, 0);
			
			if ($total != 1){
				return false;
			
			}else {
				return true;		
			}			
		}  

		//puščati povzetek of vseh blog objav.
		function get_posts(){
			
		$sql =		
			"SELECT
 				`posts`.`post_id` AS `id`,       
                `posts`.`post_title` AS `title`,
                LEFT(`posts`.`post_body`, 512) AS `preview`,
                `posts`.`post_user` AS `user`,
                DATE_FORMAT(`posts`.`post_date`,'%d/%m/%Y %H:%i:%s') AS `date`,
                `comments`.`total_comments`,
                DATE_FORMAT(`comments`.`last_comment`, '%d/%m/%Y %H:%i:%s') AS `last_comment`
            FROM `posts`
            LEFT JOIN (
            SELECT
                `post_id`,
                COUNT(`comment_id`) AS `total_comments`,
                MAX(`comment_date`) AS `last_comment`
            FROM `comments`
            GROUP BY `post_id`  
            ) AS `comments`
            ON `posts`.`post_id` = `comments`.`post_id`
            ORDER BY `posts`.`post_date` DESC";
		
		
			
			
		
			$posts = mysql_query($sql);
					
				$rows = array();
				while (($row = mysql_fetch_assoc($posts)) !== false){
				$rows[] = array(
						'id'				=> $row['id'],
						'title'				=> $row['title'],
						'preview'			=> $row['preview'],
						'user'				=> $row['user'],
						'date'				=> $row['date'],
						'total_comments'	=> ($row['total_comments'] === null) ? 0 : $row['total_comments'],
						'last_comment'		=> ($row['last_comment'] === null) ? 'never' : $row['last_comment']	
				);
				}
				return $rows;
		}
		
		//puščati enojni post iz table
		function get_post($pid) {
				$pid = (int)$pid;
				
				$sql = "SELECT
						`post_title` AS `title`,
						`post_body` AS `body`,
						`post_user` AS `user`,
						`post_date` AS `date`
					FROM `posts`
					WHERE `post_id` = {$pid}";
					
				$post = mysql_query($sql);
				$post = mysql_fetch_assoc($post);
		
				$post['comments'] = get_comments($pid);
				
		return $post;
		}
		
		//dodajaš nov blog objava
		function add_post($name, $title, $body) {
			$name = mysql_real_escape_string(htmlentities($name));
			$title = mysql_real_escape_string(htmlentities($title));
			$body = mysql_real_escape_string(nl2br(htmlentities($body)));
		
		mysql_query("INSERT INTO 'posts' ('post_user', 'post_title', 'post_body', 'post_date') VALUES ('{$name}', '{$title}', '{$body}', NOW())");
		
		}
?>
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

Re: blog tutorial need help/part05

Post by hellboj »

hellboj wrote:and this is my
post.inc.php
<?php
		// preveri če je post id v tabli.
		function valid_pid($pid) {
		
			$pid = (int)$pid;
			
			$total = mysql_query("SELECT COUNT(`post_id`) FROM `posts` WHERE `post_id`  = {$pid}");
			$total = mysql_result($total, 0);
			
			if ($total != 1){
				return false;
			
			}else {
				return true;		
			}			
		}  

		//puščati povzetek of vseh blog objav.
		function get_posts(){
			
		$sql =		
			"SELECT
 				`posts`.`post_id` AS `id`,       
                `posts`.`post_title` AS `title`,
                LEFT(`posts`.`post_body`, 512) AS `preview`,
                `posts`.`post_user` AS `user`,
                DATE_FORMAT(`posts`.`post_date`,'%d/%m/%Y %H:%i:%s') AS `date`,
                `comments`.`total_comments`,
                DATE_FORMAT(`comments`.`last_comment`, '%d/%m/%Y %H:%i:%s') AS `last_comment`
            FROM `posts`
            LEFT JOIN (
            SELECT
                `post_id`,
                COUNT(`comment_id`) AS `total_comments`,
                MAX(`comment_date`) AS `last_comment`
            FROM `comments`
            GROUP BY `post_id`  
            ) AS `comments`
            ON `posts`.`post_id` = `comments`.`post_id`
            ORDER BY `posts`.`post_date` DESC";
		
		
			
			
		
			$posts = mysql_query($sql);
					
				$rows = array();
				while (($row = mysql_fetch_assoc($posts)) !== false){
				$rows[] = array(
						'id'				=> $row['id'],
						'title'				=> $row['title'],
						'preview'			=> $row['preview'],
						'user'				=> $row['user'],
						'date'				=> $row['date'],
						'total_comments'	=> ($row['total_comments'] === null) ? 0 : $row['total_comments'],
						'last_comment'		=> ($row['last_comment'] === null) ? 'never' : $row['last_comment']	
				);
				}
				return $rows;
		}
		
		//puščati enojni post iz table
		function get_post($pid) {
				$pid = (int)$pid;
				
				$sql = "SELECT
						`post_title` AS `title`,
						`post_body` AS `body`,
						`post_user` AS `user`,
						`post_date` AS `date`
					FROM `posts`
					WHERE `post_id` = {$pid}";
					
				$post = mysql_query($sql);
				$post = mysql_fetch_assoc($post);
		
				$post['comments'] = get_comments($pid);
				
		return $post;
		}
		
		//dodajaš nov blog objava
		function add_post($name, $title, $body) {
			$name = mysql_real_escape_string(htmlentities($name));
			$title = mysql_real_escape_string(htmlentities($title));
			$body = mysql_real_escape_string(nl2br(htmlentities($body)));
		
		mysql_query("INSERT INTO 'posts' ('post_user', 'post_title', 'post_body', 'post_date') VALUES ('{$name}', '{$title}', '{$body}', NOW())");
		
		}
?>
when i post i comment come error:
in browser root: http://localhost/blog/blog_read.php?pid=1 i relly don't now where is problem in blog_read.php,tnx for helping me ....
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: blog tutorial need help/part05

Post by Temor »

You're gonna have to be patient. Stop spamming. I'm doing this on my spare time while having a job and studying.
hellboj
Posts: 18
Joined: Sat Jan 28, 2012 9:16 pm

Re: blog tutorial need help/part05

Post by hellboj »

Temor wrote:You're gonna have to be patient. Stop spamming. I'm doing this on my spare time while having a job and studying.
No problem, i find a solution i add
top of page <?ob_start();?> and end of the page <?ob_flush();?>

tnx and i hope you not angry,super tutorial.
Post Reply