-2
I have this code and you give me the following mistake:
Notice: Undefined index: ID in
<?
require('../members/inc/config.php');
require('../lib/framework.php');
// load the configuration file.
$newsid = $_GET['ID'];
$stmt = $db->query("SELECT * FROM news ORDER BY id = '$newsid' ");
while($myrow = $stmt->fetch(PDO::FETCH_ASSOC)) {
//now print the results:
echo "<b>Title: ";
echo $myrow['Title'];
echo "</b><br>On: <i>";
echo $myrow['Date'];
echo $myrow['Embed'];
echo "</i><hr align=left width=160>";
echo $myrow['Hour'];
// Now print the options to (Read,Edit & Delete the news)
echo "<br><a href=\"testonho.php?newsid=$myrow[ID]\">Read More...</a>
|| <a href=\"edit_news.php?newsid=$myrow[ID]\">Edit</a>
|| <a href=\"delete_news.php?newsid=$myrow[ID]\">Delete</a><br><hr>";
}//end of loop
?>
I have seen other issues related to this error here on Stackoverflow and I didn’t really find what I wanted. I would like a help to the resolution to this my problem :
shows me nothing..
– Rodrigo Pacheco
The error happens on the line of
$_GET
? ofprint_r($_GET);
– rray
Yes, on line 6, this:
$newsid = $_GET['ID'];
– Rodrigo Pacheco
Could you put the result of
print_r($_GET)
– rray
I’ve done it and nothing comes up. No results..
– Rodrigo Pacheco
I could put the html on that one
$_GET
, is usually a link or a<form>
– rray
That’s right, it’s suspoto I call the script by the link so:
?newsid=ID_DA_NOTICIA
– Rodrigo Pacheco
Then you should call
$newsid = $_GET['newsid']
in place of$newsid = $_GET['ID']
.– rray
This solved my error, but does not just select the id I selected.. ss
– Rodrigo Pacheco