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
Share on other sites

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.