Hello, I have a problem retrieving a random string from my database when placed in a function. Outside the function, it works fine. The function looks something like this:
function word($i) { $conword = mysql_result($con[$i], rand(0,mysql_query("SELECT COUNT(*) FROM $conname[$i]"))); echo $conword; }
You're not passing the database info in the function.
i.e.
function word($i,$dbname, $dbhost, $dbuser, $dbpassword, $dbtable){
Then connect to the db inside the function, the way you did it ouside.