Jump to content

[SOLVED] Query Problem


washinb

Recommended Posts

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);
?>

Link to comment
https://forums.phpfreaks.com/topic/43665-solved-query-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.