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 233805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:08:00+00:00 2026-05-11T20:08:00+00:00

The user comes to this page from a different page where they click on

  • 0

The user comes to this page from a different page where they click on a link and it is appended with a ?photo_id= and then the id number. I want certain information to be available to the viewer when they arrive at this page.

I want them to be able to see the photo, the photo name, and the photographers name. The first two are not a problem, because the photo_id, photo_filename, and photo_title are all in the same table. As soon as I try to get information about this photo that is on a different tabled called photographers, that’s when I experience problems.

Here’s my code:

$sql = 'SELECT photos.photo_id, photos.photo_title, photos.photo_filename, photos.photographer_id, photographers.photographer_id, photographers.photographer_name
       FROM photos
       LEFT JOIN photographers ON photos.photographer_id = photographers.photographer_id
       WHERE photo_id = ?';

//initialize prepared statement
$stmt = $conn->stmt_init(); 
if ($stmt->prepare($sql)) { 
  $stmt->bind_param('i', $_GET['photo_id']); 
  $stmt->bind_result($photo_id, $photo_title, $photo_filename, $photographer_id); 
  $OK = $stmt->execute(); 
  $stmt->fetch();
}

The first three variables($photo_id, $photo_title, and $photo_filename) work fine and I can echo them out on my page, but the other variables that I added from the LEFTJOIN such as photographers.photographer_id and photographers.photographer_name which are from a different table, will not work. As it is know, the page totally breaks when I do add the extra column names on the SELECT line.

I have a feeling it has something to with the amount of variables in the bind_result() function. I think they need to match the number of columns mentioned on the SELECT line, but I don’t really want to create a variable for each one.

Can anybody help me out?

  • 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-11T20:08:00+00:00Added an answer on May 11, 2026 at 8:08 pm

    Like you mentioned, you’re selecting six columns but only binding the first four. If you don’t need all six of those columns, don’t select them. It isn’t necessary to select the column you’re joining on, if that’s what you’re thinking.

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

Sidebar

Related Questions

When a user comes across your site's 404 File Not Found error page, it
I have a Timestamp value that comes from my application. The user can be
I have currently created a facebook like page that pulls notifications from different tables,
We are building a configurator application for conveyors. Basically user comes in and picks
When a user request comes in, I can use Context.Request.UserHostAddress to get the user's
I am trying to get the source page of a webpage on a different
Hi i am looking for an events calendar where user can come in and
I am trying to come up with such a solution that the user is
User equals untrustworthy. Never trust untrustworthy user's input. I get that. However, I am
User kokos answered the wonderful Hidden Features of C# question by mentioning the using

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.