Forum Moderators: coopster

Message Too Old, No Replies

Problems with making mysql spit out a row.

         

GamingLoft

6:30 pm on Jul 28, 2007 (gmt 0)

10+ Year Member



You can view my page here, <removed> on the 2nd page (after you click a link) there should be a number which is loaded from mysql the number is in a row called firstpost
and its not loading this number, i dont know whats wrong but

i have a feeling its this line:
WHERE tid=' . $urltid . '") or die(mysql_error());

$urltid = $_GET['tid'];

// Only Gets the row with where the tid from url and the tid are equal
$tidcheck = mysql_query("SELECT * FROM ".TABLE_PREFIX."threads
WHERE tid=' . $urltid . '") or die(mysql_error());

while($tid = mysql_fetch_array( $tidcheck )){
echo $tid['firstpost'];
}

?>

[edited by: jatar_k at 8:09 pm (utc) on July 28, 2007]
[edit reason] no urls thanks [/edit]

Tastatura

7:10 pm on Jul 28, 2007 (gmt 0)

10+ Year Member



Hi,
use "example.com" in postings to the forum rather then your real url (it might be seen as spamming and from your perspective you don't reveal how particular site works (in case someone wants to be malicious...)

is tid in database CHAR or ant type of text field or INT or other numeric?

with code you have shown (i think that) you are trying to read character value due to presence of ' around $urltid (i.e you are trying to read 'somevalue'). If tid is numberic you don't need ' around somevalue.

what is TABLE_PREFIX - a variable (if so it needs $ )?
also it looks like you have issue with quotes. strat with this and see what happens:

$sql_q = "SELECT * FROM ".$TABLE_PREFIX."threads WHERE tid='" . $urltid . "')";
$tidcheck = mysql_query($sql_q)
or die ('I cannot get data from db because: ' . mysql_error());

GamingLoft

7:33 pm on Jul 28, 2007 (gmt 0)

10+ Year Member



Thanks for the advice about the malicious people

table prefix is something to do with mybb, im getting the info loaded from mybb forums thats why

and tid is a int

i tried what you said and this is what came out

I cannot get data from db because: 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.

obviously theres a problem with the sql syntax i just dont know what.

GamingLoft

8:52 pm on Jul 28, 2007 (gmt 0)

10+ Year Member



got it to work somehow...