473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Print query when I parse ID

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
2 4332
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
Thank you. Now it works!

Ricki
Jul 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Mike Bridge | last post by:
I am using MS Access 2003, and I typed in a query in SQL view which was working fine. Now when I open it, it gives me the error "Join expression not supported". Apparently, Access "fixed" it for...
0
by: Paul | last post by:
Occasionally my users will try to perform an action and be presented with an exception raised directly from SQL Server, in example: SET @err = 'a user-friendly error condition message'...
1
by: kevin | last post by:
I thought that the parse query feature in Query Analyzer simply wrapped your statement in a TRAN and then issued a ROLLBACK statement to prevent making real changes... but i just had a query parse...
9
by: JT | last post by:
I am working on a basic webpage in PHP connecting to a mySQL database, here is my query... //query 1 $query_rs_staff = "SELECT * FROM jtStaff WHERE locationID=".$_GET; $rs_staff =...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
11
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code...
1
by: shapper | last post by:
Hi, On a form I have an input where tags are inserted in a CSV format. Then on my code I convert the CSV string to a List<Tag>. Tag is an object with two properties: TagID and Name So when I...
2
by: dmorand | last post by:
When I try to print a 'print version' of my page it looks fine in IE 7, but when I print in IE 6 the margins are all screwed up. The page itself looks the same in both browsers, it's just when I...
9
by: happyse27 | last post by:
Hi All, In perl script(item b below) where we check if html registration form are filled in properly without blank with the necessary fields, how to prompt users that the field are incomplete...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.