I'm calling saveVideo.php via ajax and $result always has two linebreaks at the top, I don't see where they could be coming from. It should be simply the $id variable in addVideo. I need the id to ajax in the new video once it's uploaded.
Even with trim(), the output from the saveVideo ajax call in Developer tools has 2 linebreaks in front of it.
Here's all the relevant code:
saveVideo.php:
<?php
require_once '../model.php';
$m = new Model;
$video = new Video;
$user = requireLogin();
$video->file = $_POST['url'];
$video->lib = 0; //sets library to be personal.
$video->title = mysql_escape_string($_POST['video-title']);
$video->desc = mysql_escape_string($_POST['video-description']);
$video->userId = $user->id;
$result = $m->addVideo($video);
echo trim($result);
?>
the addVideo function:
function addVideo($video, $lib = 1) {
// Adds video to database and associates it with a user id
$qstring = "mysqlquery";
$result = mysql_query($qstring);
$id = mysql_insert_id();
if (!$result) {
die("Error adding video to database.");
}
return $id;
}