I’m trying to get a function to work (Extremely new to functions btw) And this is what I have, but when I implement it into my page it doesn’t turn any results. Is anybody able to see what’s wrong in this?
public function get_character() {
$con=mysql_connect("****","****","****");
mysql_select_db("accounts", $con);
$id = mysql_query("SELECT id FROM account WHERE username = '" . $username . "'");
global $characterdb;
$info = $characterdb->get_row("SELECT `name` FROM `characters` WHERE `account` = '" . $characterdb->escape($id) . "' AND `active`=1");
if(is_object($info))
return $info->character;
else
return '';
}
Your
$idis a Mysql Result, not an integer that you can use in another query.First you will need to get the row and the id from that row.
Also: consider handing $characterdb to the function as an argument or have it as a class variable.
Importing it via global is the least attractive option. 😉