PDA

View Full Version : need help w/ a quick little script


01-11-2001, 01:17 PM
basically i'd like to input a thread name a la:

script.php?subject=Blah

and then do

$thread = "News: ".$subject;

and then pull the latest thread with that name out of the db, get its threadid, and print a header redirecting the person to that thread.

this isnt working though:

<?
require("global.php");

$title="News: ".$subject;
// echo "$title"; //debug
$threads = $DB_site->query("SELECT threadid FROM thread WHERE title=$title");
while ($thread = $DB_site->fetch_array($threads)) {
// echo "$thread[0]"; //debug
$url="http://www.tribalwar.com/forums/showthread.php?threadid=".$thread[0];
// echo "<a href=$url>test</a>"; //debug
header("Location: $url");
}
?>


it gives me a mysql syntax error, but i've no idea where it is.

this is for the newspro/vB integration, im working on a 'Comment on this news>>' link, and eventually i'd like to put the newsid in the thread\notes part of the table, but i thought i'd stick to this for now. any ideas?

01-11-2001, 02:27 PM
$threads = $DB_site->query("SELECT threadid FROM thread WHERE title='".addslashes($title)."'");

01-11-2001, 02:45 PM
i love you :D