So I have this function that gets data from database and echoes it. The function takes from the database the article id, article title, and some other data..
When the user is not logged in, the function works good and shows all the data, but when a user is logged in, suddenly only the article title is fetched.. All the data is in the same database and even in the same table but only the article id is fetched!!
Notes:
- In my localhost this is not happening.
- My host is ipage.com and in order to get php sessions to work I need to add session_save_path(//path) before session_start() (I don't know if this has something to do with the problem)
Update:
This is the error: Warning: implode() [function.implode]: Invalid arguments passed in /path
This is the function:
function getNowPlaying($stmt) {
$sql = 'SELECT movies.imdbID, movies.title FROM movies ORDER BY Rand() LIMIT 15';
if ($stmt->prepare($sql)) {
$stmt->bind_result($imdbID, $title);
$stmt->execute();
$i = 0;
while ($stmt->fetch()) {
$data[$i]["imdb"] = zeroFill($imdbID);
$data[$i]["title"] = $title;
$i++;
}
}
for ($i = 0; $i < count($data); $i++) {
$genres = getGenre($stmt, $data[$i]["imdb"]);
$data[$i]["genre"] = implode(', ', $genres);
$data[$i]["poster"] = getPoster($stmt, $data[$i]["imdb"]);
}
return $data;
}
function getGenre ($stmt, $id, $db = 'main') {
if ($db === 'main') {
$sql = 'SELECT sys_genres.genre FROM sys_genres, movie_genres WHERE sys_genres.genreID = movie_genres.genreID AND movie_genres.imdbID = ?
ORDER BY movie_genres.genreORDER';
}
else if ($db === 'inp') {
$sql = 'SELECT sys_genres.genre FROM sys_genres, inp_movie_genres WHERE sys_genres.genreID = inp_movie_genres.genreID AND inp_movie_genres.imdbID = ?
ORDER BY inp_movie_genres.genreORDER';
}
if ($stmt->prepare($sql)) {
$stmt->bind_param('i', $id);
$stmt->bind_result($genres);
$stmt->execute();
while ($stmt->fetch()) {
$data[] = $genres;
}
}
if (!empty($data)) {
return $data;
}
}
The Session array when user is logged in:
Array
(
[xsrf_token] => 13721578024c33e20b2940d3.39161731
[username] => jonagoldman
[userID] => 24
[start] => 1278468629
)
Update 2:
This is the part that is causing problems:
In index.php I have this:
if (isset($_SESSION['userID'])) {
$user_points = getUserPoints($stmt, $_SESSION['userID']);
}
function getUserPoints($stmt, $userid) {
$sql = 'SELECT points FROM user_points WHERE userID = ? LIMIT 1';
if ($stmt->prepare($sql)) {
$stmt->bind_param('i', $userid);
$stmt->bind_result($data);
$stmt->execute();
$stmt->fetch();
}
if (!empty($data)) {
return $data;
}
}
That part of code is causing the problem when the user log in.. Any ideas?