Q:

Why can't I pass a connection variable to my function?

I can't seem to figure out why my function is not seeing $conn variable. Other functions seem to work just fine.
Here is a file in which I am calling my function:
require_once('../functions.php');
if('POST' == htmlspecialchars($_SERVER['REQUEST_METHOD'])) {     
    $user_id = $_SESSION["user_id"];
    $day = $_POST["day"];
    $month = $_POST["month"];
    $year = $_POST["year"];
    $type = '';
    $content = $_POST["content"];
    add_bullet($user_id, $day, $month, $year, $type, $content, $conn);   
}

And here is my functions.php
require_once('../include/db_connect.php');    
// other functions here..   
function add_bullet($user_id, $day, $month, $year, $type, $content, $conn) {    
    $sql = "INSERT INTO `mbt`.`bullets` (`id`, `user`, `day`, `month`, `year`, `type`, `content`) VALUES ('', '$user_id', '$day', '$month', '$year', '$type', '$content');";
    mysqli_query($conn, $sql);      
}

My other functions seem to work just fine using same method.
Here is my db_connect.php
$dbserver = "xxx"; 
$dbuser = "xxx"; 
$dbpassword = "xxx"; 
$dbname = "xxx"; 

$conn = new mysqli($dbserver, $dbuser, $dbpassword, $dbname); 

if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }

A:

You can't just use what ever variable you want from other files..
Add this global and try then..
$content = $_POST["content"];
global $conn;
add_bullet($user_id, $day, $month, $year, $type, $content, $conn);

A better idea is to define function inside your db file which will return the connection, this way you wont need to pass it but just to use the method..

