...

View Full Version : PHP? Help



Dfraz
02-21-2008, 05:13 AM
I want it where that page exists but in a way it doesn't.

Just like other forums...

You view the subject of topics right? The topic you wanna see you click it and it brings you to that page.
What I have is where you see the topics but when you click into it it goes to a blank page when It should be the page that they wanted to see.

That's it. here is the code to where you click the topic you want:


echo ''.$row['subject']. "<a href='http://www.frazierfilms.fragvault.com/forum/showtopic.php?id='>Go to the topic</a>";

And here is the code that IS the page that gets the message of which topic you clicked:


<?php
$id = $_GET['id'];
$message = $_GET['message'];
$id = mysql_real_escape_string($id);
$message = mysql_real_escape_string($message);
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM topics WHERE `id`='$id'")
or die(mysql_error());


echo " <table border='1' 'width = 92&#37;' > ";

echo "<tr> <th>Shows</tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo ''.$row['message'];
echo "</td></tr>";
}

echo "</table>";
?>

Please help, thanks

oesxyl
02-21-2008, 05:23 AM
do you mean that when you click on "Go to topic" you see the php code?

best regards

Dfraz
02-21-2008, 05:25 AM
I mean where when you click into the topic it views the message and stuff just like normal forums.
You click into THIS topic and see what we've said. That is what I mean!

oesxyl
02-21-2008, 05:28 AM
I mean where when you click into the topic it views the message and stuff just like normal forums.
You click into THIS topic and see what we've said. That is what I mean!

THIS must be your thread on codingforums?

best regards

Dfraz
02-21-2008, 05:29 AM
Right it is. Just please tell me how I can do that. Edit the code and fix it please.

_Aerospace_Eng_
02-21-2008, 05:35 AM
You need the id of the thread. You don't seem to have that in your code. We can't tell what the id of the thread is of your specific forum. Also we are here to help you but if you don't give enough information to help you we can't. We aren't here to just fix things for you because you didn't try to.

Dfraz
02-21-2008, 05:39 AM
I understand.

But I've been trying for more then 3 hours straight!

I edited the post I think and I think I put it right.

But when I click the topic I want the description is EMPTY.
Here take a try. http://www.frazierfilms.fragvault.com/forum/athreads.php

_Aerospace_Eng_
02-21-2008, 05:46 AM
Your query should probably be failing as id is a likely an integer not a string. Try

<?php
$id = '';
if(isset($_GET['id']))
{
$id = intval($_GET['id']);
}
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM topics WHERE `id`= $id") or die(mysql_error());


echo " <table border='1' width = '92&#37;' > ";

echo "<tr> <th>Shows</tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['message'];
echo "</td></tr>";
}

echo "</table>";
?>
Make sure you are connecting to the database properly as well. You aren't using $_GET['message'] anywhere in your query so you don't need it. Why are you trying to make your own forum? Its clear that you aren't that experienced yet. You are better off downloading and installing an existing forum like phpbb or something.

Dfraz
02-21-2008, 06:01 AM
Now it says
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

_Aerospace_Eng_
02-21-2008, 06:04 AM
Right because you aren't passing anything to the url. You NEED to pass the id of the thread to the url. Try this

<?php
$id = (isset($_GET['id'])) ? intval($_GET['id']) : 1;

// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM topics WHERE `id`= $id") or die(mysql_error());


echo " <table border='1' width = '92&#37;' > ";

echo "<tr> <th>Shows</tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['message'];
echo "</td></tr>";
}

echo "</table>";
?>
Its probably still not going to bring anything up because you need to give it a valid id of a thread. So now go into your database and get an id from a thread and then use the url
http://www.yoursite.com/showthread.php?id=12345 where 12345 is the id you got from the database.

Dfraz
02-21-2008, 06:09 AM
Now it works but it's empty.

It should have whatever the user put for the message

_Aerospace_Eng_
02-21-2008, 06:17 AM
I don't think you understand how databases work. The user submits a post, the post goes into the database with an id. Then the page is called with the id as a query string. The id is used to pull the correct message from the database. If you don't store the message anywhere its not going to show up. So now WHAT is in your database? Do you even have one?

Dfraz
02-21-2008, 06:20 AM
I have a database.
I have it to insert into the database.
I have a ID, Message and Subject column in my database.

And now all I'm trying to do is get it to view the topic I want it to view.

EXAMPLE!!!

When I click into this topic I want to see what I've said.
In the case I've got on mine now. You click in the topic and it's completly Empty.

_Aerospace_Eng_
02-21-2008, 06:21 AM
Okay the code above is what page? What is the url to that page? Also do you HAVE an ID of a message in your database? If so what is it?

Dfraz
02-21-2008, 06:23 AM
The Ids
Are.
10

and

11

the url is: frazierfilms.fragvault.com/showtopic.php

_Aerospace_Eng_
02-21-2008, 06:28 AM
Now won't you look at that?
http://www.frazierfilms.fragvault.com/forum/showtopic.php?id=10
and
http://www.frazierfilms.fragvault.com/forum/showtopic.php?id=11
As I've been telling you, you NEED to pass the id to the url in showtopic.php.

Dfraz
02-21-2008, 06:33 AM
I got it to work.

_Aerospace_Eng_
02-21-2008, 06:38 AM
You're welcome.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum