PollyJuice
Technical User
I'm making a forum with php and mysql. I have a webserver and a database (WAMP).
Once a user is logged in, he/she can see the titles of the threads on a page called index_online_php. Each thread is a link to another page called enskildtrad.php, where I want to print the thread they have clicked on, with its title, author and date, and a little further down also the answers that have been made to this particular thread.
Here's how I have written the code on index_online.php:
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
print "<tr><td width=\"50px\"><a href=\"enskildtrad.php?id=" . $row['threadID'] . "\">" . $row['threadID'] . "</a></td>";
print "<td width=\"100px\">" . $row['titel'] . "</td>";
}
print "</table>";
and on the page enskildtrad.php, I've written:
if (isset($_SESSION['userid'])) {
$tradid = (int)$_GET["threadID"];
$conn = mysql_connect("xx.xxx.xx.xxx", "xxxxxx", "xxxxxxxx") or die("Could not connect: " . mysql_error());
$db_selected = mysql_select_db("grafiket", $conn) or die("Can't use testdb : " . mysql_error());
$kvajry = "SELECT * FROM thread T WHERE T.threadID=$tradid";
$result = mysql_query($kvajry);
...
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
print "<tr><td width=\"150px\" class=\"brodtext\"><img src=\"" . $row['avatar'] . "\">";
print "<br />" . $row['User_Name'] . "</td>";
print "<td width=\"450px\" class=\"brodtext\">" . $row['titel'] . " | " . $row['datum'] . "<hr>" . $row['text'] . "</td></tr>";
}
print "</table>";
But when I test it, all I get when I click a link is the table with Författare and Tråd and no values. I suspect there is something wrong with the line
$tradid = (int)$_GET["threadID"];
or possibly in how I've written the link. Any suggestions on how I can fix this? Pretty please?
Once a user is logged in, he/she can see the titles of the threads on a page called index_online_php. Each thread is a link to another page called enskildtrad.php, where I want to print the thread they have clicked on, with its title, author and date, and a little further down also the answers that have been made to this particular thread.
Here's how I have written the code on index_online.php:
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
print "<tr><td width=\"50px\"><a href=\"enskildtrad.php?id=" . $row['threadID'] . "\">" . $row['threadID'] . "</a></td>";
print "<td width=\"100px\">" . $row['titel'] . "</td>";
}
print "</table>";
and on the page enskildtrad.php, I've written:
if (isset($_SESSION['userid'])) {
$tradid = (int)$_GET["threadID"];
$conn = mysql_connect("xx.xxx.xx.xxx", "xxxxxx", "xxxxxxxx") or die("Could not connect: " . mysql_error());
$db_selected = mysql_select_db("grafiket", $conn) or die("Can't use testdb : " . mysql_error());
$kvajry = "SELECT * FROM thread T WHERE T.threadID=$tradid";
$result = mysql_query($kvajry);
...
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
print "<tr><td width=\"150px\" class=\"brodtext\"><img src=\"" . $row['avatar'] . "\">";
print "<br />" . $row['User_Name'] . "</td>";
print "<td width=\"450px\" class=\"brodtext\">" . $row['titel'] . " | " . $row['datum'] . "<hr>" . $row['text'] . "</td></tr>";
}
print "</table>";
But when I test it, all I get when I click a link is the table with Författare and Tråd and no values. I suspect there is something wrong with the line
$tradid = (int)$_GET["threadID"];
or possibly in how I've written the link. Any suggestions on how I can fix this? Pretty please?