hi guys, i'm just a beginner in PHP and i'm trying to build my own website and i have this problem:
i have this database for the articles that i want to show in my pages:
now i have written the following php scripts:
header.php
<?php
define("server","localhost");
define("db_user","myusername");
define("db_pass","mypassword");
define("db_name","articles");
define("main_title","my web site");
//connect to MySql
$connect= @mysql_pconnect(server,db_user,db_pass);
//check the connection
if (!$connect) {
die ("<center>Sorry, I am unable to esablish a connection because: ".mysql_error()." !");
}
//select database
$db_select=@mysql_select_db(db_name,$connect);
//check database selection
if (!$db_select) {
die ("<center>Sorry, I can not select the requested database because: ".mysql_error()." !");
}
?>
sport.php
<?php
include 'header.php';
//the header contains the required information to establish the connection to the //database.
$result_query=mysql_query("SELECT * FROM articles WHERE class='sport' and view='show' ORDER BY date DESC");
if (mysql_num_rows($result_query) == 0) {
echo "<center>Sorry! there is no articles in this page yet.</center>";
include 'footer.php';
exit;
}
echo("<table style='width: 400px' cellspacing='0'>");
while($result=mysql_fetch_array($result_query)){
echo ("<tr>");
echo ("<td style='border-style:none; border-width:medium; color: #008000; font-size: 14pt; font-weight: bold'><span><a href='showarticle.php?id=$result[id]' style='text-decoration: none'>$result[address]</a></span></td>");
echo ("<td style='width: 65px; font-family:Tahoma; font-size:12pt'>
<p align='center'><a href='download/$result[file]' style='text-decoration:none'>download</a></td>");
echo ("</tr>");
}
//mysql_free_result($result_query);
echo('</table>');
include 'footer.php';
?>
show_article.php
<?php
include ('header.php');
$result_query=mysql_query("SELECT * FROM articles WHERE id=id");
if(!$result_query){echo "Query did not start!";}
$result=mysql_fetch_array($result_query);
echo ($result[story]);
mysql_free_result($result_query);
include ('footer.php');
?>
the first script goes very well with me and the page displays the addresses that i want, but when i try to click on the address and go show_article.php it always shows the first article in the database whatever the ID is, i mean even if i clicked (in sport.php) on the second or third address it always shows the first article in in my database. plus it writes:
Notice: Use of undefined constant story - assumed 'story' in "C:\wamp\www\san\showarticle.php on line 6".
Thanks alot for any help