By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,216 Members | 1,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,216 IT Pros & Developers. It's quick & easy.

Print query when I parse ID

P: n/a
Hi,
Can anyone help me to get my query printed when I parse ID.

Here is the code:

[snip]

FILE: udskriv.php

<?php

include("connect.php");
mysql_select_db("DATABASE");
$result = mysql_query("SELECT ID, tekst, DATE_FORMAT(dato, '%d %m %Y
kl. %H:%i')as dato FROM TABLE ORDER BY ID desc LIMIT 0,3");
while ($raekke = mysql_fetch_array($result)){

echo"<P>Indtastet dato: ".$raekke['dato']."</P>";
$text = $raekke['tekst'];
echo nl2br(substr($text,0,50));
print "<a href='showpost.php?ID={$raekke["ID"]}'>Some Text</a>";


}
mysql_close($link);
?>

FILE: showpost.php

<?php

include("connect.php");
$ID = $_POST['ID'];
$sql = "SELECT tekst FROM TABLE WHERE ID=$ID";
$result = mysql_query($sql);
echo "her er:".$result;

mysql_close($link);


?>

[snip]

The problem is that I don't get any output from the database. Why?

Ricki
Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
sam
1-In the file showpost.php change

this line:
$ID = $_POST['ID'];
with this line:
$ID = $_GET['ID'];

You send the ID to showpost.php in the URL:
<a href='showpost.php?ID={$raekke["ID"]}'>Some Text</a>

So you get it in the $_GET array and not in the $_POST array.

2- this line is wrong (here you print the resource id):

echo "her er:".$result;

instead :
get the result from the resource id:
$txt = mysql_fetch_row($result);
print the result:
echo "her er:".$txt[0];

HTH.

"Ricki Susic" <ri*************@webfabrikken.net> wrote in message
news:3f***********************@dread12.news.tele.d k...
Hi,
Can anyone help me to get my query printed when I parse ID.

Here is the code:

[snip]

FILE: udskriv.php

<?php

include("connect.php");
mysql_select_db("DATABASE");
$result = mysql_query("SELECT ID, tekst, DATE_FORMAT(dato, '%d %m %Y
kl. %H:%i')as dato FROM TABLE ORDER BY ID desc LIMIT 0,3");
while ($raekke = mysql_fetch_array($result)){

echo"<P>Indtastet dato: ".$raekke['dato']."</P>";
$text = $raekke['tekst'];
echo nl2br(substr($text,0,50));
print "<a href='showpost.php?ID={$raekke["ID"]}'>Some Text</a>";


}
mysql_close($link);
?>

FILE: showpost.php

<?php

include("connect.php");
$ID = $_POST['ID'];
$sql = "SELECT tekst FROM TABLE WHERE ID=$ID";
$result = mysql_query($sql);
echo "her er:".$result;

mysql_close($link);


?>

[snip]

The problem is that I don't get any output from the database. Why?

Ricki

Jul 16 '05 #2

P: n/a
Thank you. Now it works!

Ricki
Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.