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
Old 06-14-2005, 12:56 PM Small problem
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
Hi everyone, i'm having a little problem with this file im currently coding. If the $_GET['story'] is used, show only the story they want, if they didnt select 1, show them all! Thats whats happening below... BUT I get an error...
Code:
Notice: Undefined index: story in c:\program files\easyphp1-8\www\news script\news.php on line 7
PHP Code:
echo("<a href=\"news.php?story=".$id."\">$title - $date - $author</a>"); 
PHP Code:
$story $_GET['story']; 
Can anyone help?

PHP Code:
<?

// Include the database connection
include("connect.php");

// Get the story variable
$story $_GET['story'];

// Is the story variable sent?
if(isset($story)) {

// Select the item from the news which they wanna view
$result=mysql_query("SELECT * FROM news WHERE id = ".$story." LIMIT 1");
while(
$row=mysql_fetch_array($result)) {

// Pull information out
$id $row['id'];
$author $row['author'];
$title $row['title'];
$content $row['content'];
$date $row['date'];

// Get rid of the dirty slashes
$date stripslashes($date);
$author stripslashes($author);
$title stripslashes($title);
$content stripslashes($content);

// Show the news which they selected
echo("$title - $date - $author");

}} else {

// Connect and show all the news
$result1=mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 5");
while(
$row=mysql_fetch_array($result1)) {

// Pull out the information
$id $row['id'];
$author $row['author'];
$title $row['title'];
$content $row['content'];
$date $row['date'];

// Get rid of the dirty slashes
$date stripslashes($date);
$author stripslashes($author);
$title stripslashes($title);
$content stripslashes($content);

// Show it to them, including the link for just 1 story
echo("<a href=\"news.php?story=".$id."\">$title - $date - $author</a>");
}}

?>
feraira is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-14-2005, 04:21 PM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
what code did your get ???
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 06-14-2005, 06:45 PM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
It didn't say a code, just said "notice"
feraira is offline
Reply With Quote
View Public Profile
 
Old 06-19-2005, 09:25 PM
SpottyDog's Avatar
Skilled Talker

Posts: 82
Trades: 0
can you not just add an if statement to check if there is a value to $story and if there isnt, echo 'sorry you must select an article'

Last edited by SpottyDog; 06-19-2005 at 09:25 PM.. Reason: bloody typo's
SpottyDog is offline
Reply With Quote
View Public Profile
 
Old 06-20-2005, 05:11 PM
Novice Talker

Posts: 9
Location: Moscow, Russia
Trades: 0
There is an error in your syntax

// Get the story variable
$story = $_GET['story'];

// Is the story variable sent?
if(isset($story)) {

use this instead:

// Is the story variable sent?
if(isset($_GET['story'])) {

$story = $_GET['story'];
PiterZ is offline
Reply With Quote
View Public Profile Visit PiterZ's homepage!
 
Old 06-21-2005, 03:51 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
PiterZ is correct - you're getting that notice because the $story variable isn't defined, so the script stops before it even gets to the if-statement. Thus, this means that the $_GET probably isn't being sent through and so the error may be routed slightly deeper.
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Small problem
 

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.17528 seconds with 12 queries