washinb Posted March 21, 2007 Share Posted March 21, 2007 list.php will result a list of headline story (slug) stored in MYSQL which had link to query the full story via story.php. The problem : when the link is clicked, the story.php return error "no such story in database". the link is built based on unique id number. This 2 script used to be working fine until about last year. Any suggestion is appreciated. thanks, -bw list.php <?php // includes include("../conf.php"); include("../functions.php"); // open database connection $connection = mysql_connect($host, $user, $pass) or die ("can not connected"); // select database mysql_select_db($db) or die ("can not select database"); // ambil hasil $result = mysql_query("SELECT id, contact, slug, timestamp FROM bahasa ORDER BY timestamp DESC LIMIT $offset, $limit") or die ("salah query : $query. " . mysql_error()); while($row = mysql_fetch_object($result)) { ?> <li style="list-style: none;"> <a id="judul" href="b_story.php?id=<? echo $row->id; ?>"><? echo $row->slug; ?></a><br> <li style="padding-bottom: .8em; font-size: 75%; list-style: none; font-family: verdana;">Publikasi tanggal <? echo formatDate($row->timestamp); ?> - Sumber : <font color="green"><? echo $row->contact; ?></font> <? } ?> story.php <? // includes include("../conf.php"); include("../functions.php"); // open database connection $connection = mysql_connect($host, $user, $pass) or die ("can not connect to database"); // select database mysql_select_db($db) or die ("can not select database"); // generate and execute query $query = "SELECT slug, content, contact, timestamp FROM bahasa WHERE id='$id'"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); // get resultset as object $row = mysql_fetch_object($result); // print details if ($row) { ?> <p style="font-family: trebuchet ms; font-size: 120%; font-weight:bold;"><? echo $row->slug; ?><br> <p style="line-height: 150%;"><? echo nl2br($row->content); ?> <p style="font-family: verdana;font-size: 75%;">Publikasi cerita disini pada tanggal <? echo formatDate($row->timestamp); ?> - Sumber : <font color="green"><? echo $row->contact; ?></font></p> <? } else { ?> <p> <font size="-1">no such story in database</font> <? } // close database connection mysql_close($connection); ?> Quote Link to comment Share on other sites More sharing options...
artacus Posted March 21, 2007 Share Posted March 21, 2007 Yeah, you need to address $id as $_GET['id']. Quote Link to comment Share on other sites More sharing options...
washinb Posted March 22, 2007 Author Share Posted March 22, 2007 Yeah, you need to address $id as $_GET['id']. Thanks artacus, It works great now. Just curious, is that rules change in PHP ? since what version ? thanks again, -bw Quote Link to comment Share on other sites More sharing options...
btherl Posted March 22, 2007 Share Posted March 22, 2007 It depends on the setting of "register_globals". It used to be usually on on php sites, but now it is usually off by default, as it increases security risks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.