Hi, I'm new in php, I get this error, can you please fix this.
I need $_GET['post_id'] for get the data from my db with 'unique id', So that It's need 'post_id'. I'm check the $_GET['post_id'] but it's show "'Required variable is not set".
How do i set the variable or how do fix this problem, Don't worry because of i'm new PHP WORLD
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
include "db/db.php";
$upload_path = "secure/content/blogpostimg";
if (isset($_GET['post_id']))
{
$p_id = (int) $_GET['post_id'];
}
else
{
die('Required variable is not set');
}
$sql = "SELECT * FROM blog_post WHERE post_id = '$p_id'";
$res = mysql_query($sql) or trigger_error(mysql_error()." ".$sql);
if (!mysql_num_rows($res))
{
die("No records found");
}
while ($rel = mysql_fetch_assoc($sql))
{
$id = $rel['post_id'];
$sub = $rel['subject'];
$imgname = $rel['img_name'];
$img = $rel ['image'];
$msg = $rel['message'];
$date = $rel['date'];
$poster = $rel['poster'];
$cat_name = $rel['cat_name'];
?>
<span id="post">
<?php
echo "<h1>". "$sub" ."</h1>". "<br/>";
?>
<?php
echo '<img src="' . $upload_path . '/' . $imgname . '" width="200" /> ';
?>
<?php
include_once("func.php");
echo truncate($rel['message'],"index.php","post_id",$rel['post_id']);
?>
Many Thanks,
Shibbir.