Jump to content

Recommended Posts

i have two scripts, the first displays a list of article names generated from a table, the user would then click a link, and depending on which link they click, the script is supposed to use the id number on the next script on the viewArticle page and draw that information from the table and display it. but i keep getting this file does not exist. where am i going wrong please?

 

Article list:

<?php
$con = mysql_connect("localhost","fghm1","ixfgdmghm");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("bncvm", $con);


   $query = "SELECT * FROM `Animals` ORDER BY `ID`";

        $result = mysql_query($query);

$num=mysql_num_rows($result);
$i=0;


while ($i < $num) {
$ArtID=mysql_result($result,$i,"ID");
$Article=mysql_result($result,$i,"Article");
$url="index.php?page=";

echo '<tr><td width=5></td><td align=center><a href="index.php?page=viewArticle">'.$Article.'</a></td></tr>';

++$i;
}
?>

 

View article script

<?php
$con = mysql_connect("localhost","fghjhk","ifghkhjk8");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("sfsgh", $con);

$page = $_GET['ID']; // This will be the ID of the page
$page = mysql_real_escape_string(strip_tags($page));

  $query = mysql_query("SELECT * FROM Animals WHERE `ID` = '$page'");

   if(mysql_num_rows($query)==0){

    die("Sorry, but that page does not exists $row");

      }else{
         
        while($row = mysql_fetch_array($query)){

          echo $row['Article'] . "<br>";
          echo $row['Text'] . "<br>";
             
          }
             
     }

?>

Link to comment
https://forums.phpfreaks.com/topic/88085-solved-where-am-i-going-wrong/
Share on other sites

Modify this line:

 

echo '<tr><td width=5></td><td align=center><a href="index.php?page=viewArticle">'.$Article.'</a></td></tr>';

 

to be:

 

echo '<tr><td width=5></td><td align=center><a href="index.php?page=viewArticle&ID=$ArtID">'.$Article.'</a></td></tr>';

 

that's on the article list page.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.