I am pretty new to using mysql and variables in php.
I have this code
mysql_query("INSERT INTO `forum_threads` (`name`, `byid`, `cid`,
`content`, `time`, `lastreplied_time`, `lastreplier_id`) VALUES
('{$title}', '{$uid}', '{$cid}', '{$content}', '" . time() . "', '" .
time() . "', '{$uid}');") or die(mysql_error());
In my php file, I want byid
to be the value of id
in my table forum_users
. So can I replace {$uid}
with something that will get the value from forum_users
. Because I don't think {$uid} is working correct.
I found this code
/* Non-existant forum account */ final public function
createForumAccount($uid) {
$getHabboUser = mysql_query("SELECT * FROM
`users` WHERE `id` = '{$uid}' LIMIT 1");
I assume that the function of that code is to get the {$uid}
equal the id
from the users
table, I want to make the {$uid}
to equal the id from the forum_users
table.
Then I found this code:
final public function getUserData($uid, $var) {
if($this->checkForAccount($uid) == true) {
$check = mysql_query("SELECT `{$var}` FROM `forum_users` WHERE `uid` = '{$uid}' LIMIT 1") or die(mysql_error());
return mysql_result($check, 0);
}
}
That code wants the {$uid}
to equal forum_users id
. And that is exactly what I want, but it doesn't equal that, it equals the id
from the users
table instead, I assume it might collide with eachother or something.
How can I solve this? Can I replace {$uid}
in my first code, so byid
is selected instantly from forum_users
? Can I make a new variable that equals forum_users.id
?