Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Need $_GET['id'] but it's say not set, How do fix that
Old 12-14-2011, 01:10 PM Need $_GET['id'] but it's say not set, How do fix that
Junior Talker

Posts: 3
Trades: 0
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.
Creativeartbd is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-14-2011, 01:18 PM Re: Need $_GET['id'] but it's say not set, How do fix that
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
PHP Code:
if (isset($_GET['post_id']))
{
     
$p_id = (int) $_GET['post_id'];
}
 else
{
     die(
'Required variable is not set');

If isset($_GET['post_id']) is returning false, then the URL parameter 'post_id' must not be set.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-14-2011, 01:20 PM Re: Need $_GET['id'] but it's say not set, How do fix that
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
How do i set the variable or how do fix this problem
Make sure it is on the href of the link that is being clicked on.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-14-2011, 11:42 PM Re: Need $_GET['id'] but it's say not set, How do fix that
Junior Talker

Posts: 3
Trades: 0
I don't understand , can u pls clear it more
Creativeartbd is offline
Reply With Quote
View Public Profile
 
Old 12-14-2011, 11:51 PM Re: Need $_GET['id'] but it's say not set, How do fix that
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by Creativeartbd View Post
I don't understand , can u pls clear it more
The url you used to execute that script does not specify the 'post_id' parameter. For example, the following url does specify a post_id:

http://example.com/myscript.php?post_id=1
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-14-2011, 11:55 PM Re: Need $_GET['id'] but it's say not set, How do fix that
Junior Talker

Posts: 3
Trades: 0
So, how do i specify the 'post_id' parameter or is there anything need to change in my code? pls tell me
Creativeartbd is offline
Reply With Quote
View Public Profile
 
Old 12-15-2011, 10:03 AM Re: Need $_GET['id'] but it's say not set, How do fix that
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://www.webmasterworld.com/forum88/12838.htm

http://www.rotsystems.com/tag/php-querystring-tutorial
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Need $_GET['id'] but it's say not set, How do fix that
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32640 seconds with 12 queries