Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 890505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:44:36+00:00 2026-05-15T13:44:36+00:00

So I have this function that gets data from database and echoes it. The

  • 0

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:

  1. In my localhost this is not happening.
  2. 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:44:37+00:00Added an answer on May 15, 2026 at 1:44 pm

    Nothing in your code suggests anything session related, but note that getGenre may or may not return a result. It’s unclear what a call to implode will do when getGenre returns nothing. The warning would suggest to me you’re not getting any genres back.

    Using a contrived example I can replicate your warning:

    function foo(){ }
    $bar = foo();
    echo implode(', ', $bar);
    

    Yields the warning

    Warning: implode(): Invalid arguments passed in…

    This would lead me to believe that your problem is occurring further up the chain…that is you’re observing a symptom rather than a problem.

    Evidently the core issue is that you’re passing around $stmt rather than the connection itself. The problems you’re seeing stem from code that only runs when a user is logged in. That doesn’t mean there’s a problem with your login scheme, and it’s wholly unrelated to sessions. The core issue is that when a user is logged in you’re doing something you don’t normally do with $stmt, in effect corrupting it.

    Everywhere you pass around $stmt you should be passing around your connection $conn (from your comments above I know this is $conn). Then anywhere you need a statement get one from the connection by running $stmt = $conn->stmt_init();.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a function that gets some data from the database and puts
I have this function in jQuery that gets data from a page with POST,
I have this big function (1300+ lines of code) that takes data from the
I have some data that gets pulled out of a database and mapped to
I have this function that I would like to condense into some iterator. How
I have this function that takes the input of a, runs a calculation and
I have this function that switches the HTML contents from one element on a
I'm currently writing an iPhone application which gets some data from the user and
I have a gridview that displays data from a database. The datbase stores the
i have ajax function that looks like this: jQuery.ajax({ type: 'POST', data: { action:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.