Cheers for all the replies, I have decided against global variables as everywhere ive read they are apparently bad.
Ok i have this at the top of the script:
$mysqli = new mysqli($dbhost,$dbuser,$dbpass,$db);
I have changed the function to this:
function detail_available($table,$detail,$value,$db){
/* Function for checking dupes. */
if($result = mysqli_query($db,"SELECT * FROM $table WHERE $detail = '$value'")){
$count = mysqli_num_rows($result);
if($count==0){
return true;
}else{
return false;
}
}else{
//query fail
die('query fail');
}
}
the query does not work.
I call the function like this:
if(detail_available('users','username',$username,$mysqli)){
but I believe OOP might serve you better as a learning exercise and might result in better code.
I would really like to learn some OOP but it confuses the hell out of me, thats why im trying to play with some objects and classes before I make my own.
If anyone would like some more information about what is going on please ask. Again, thanks for the help.