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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:01:00+00:00 2026-06-13T13:01:00+00:00

I am trying to write the below function to display the contents of a

  • 0

I am trying to write the below function to display the contents of a MySQL table.

$q=$_GET["q"];
function risk_allocation($db)  
  {    
    $result = $db->query("select r.risks as risks,r.risktype as risktype,j.job as job from risks r LEFT OUTER JOIN `jobsrisks` j on r.risks = j.risk and j.job=:q"); 
    $result ->bindParam(':q', $q, PDO::PARAM_INT);
    return $result; 
  }
        $allocationlist = risk_allocation($db); 

I am then calling the finction with:

while($row = $allocationlist->fetch(PDO::FETCH_ASSOC)) 
{
echo $line['risks'];
echo $line['risktype'];
}

I am receiving error message:

Fatal error: Call to a member function bindParam() on a non-object in /home/she/public_html/versionfour/getrisksperjob.php on line 11

where line 11 is

$result ->bindParam(':q', $q, PDO::PARAM_INT);

I have the feeling this is a simple question resulting from me just being introduced to pdo, but any help appreciated as always.

UPDATE

as per proposed answers, my code is now as below to execute query and to include the variabe q. same error still occurs though. Thanks for help thus far, any ideas?

Fatal error: Call to a member function bindParam() on a non-object in /home/she/public_html/versionfour/getrisksperjob.php on line 11

function risk_allocation($db,$q)  
  {    
    $result = $db->query("select r.risks as risks,r.risktype as risktype,j.job as job from risks r LEFT OUTER JOIN `jobsrisks` j on r.risks = j.risk and j.job=:q"); 
    $result ->bindParam(':q', $q, PDO::PARAM_INT);
    $result->execute();
    return $result; 
  }
  $allocationlist = risk_allocation($db,$q); 
  • 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-06-13T13:01:01+00:00Added an answer on June 13, 2026 at 1:01 pm

    1.You forgot to execute query

    $result->execute();
    

    2.$q is outside function so you will never get value of that inside function. pass $q as second parameter of function

    $q=$_GET["q"];
    function risk_allocation($db,$q)  
      {    
        $result = $db->prepare("select r.risks as risks,r.risktype as risktype,j.job as job from risks r LEFT OUTER JOIN `jobsrisks` j on r.risks = j.risk and j.job=:q"); 
        $result ->bindParam(':q', $q, PDO::PARAM_INT);
        $result->execute();
        return $result; 
      }
      $allocationlist = risk_allocation($db,$q); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a lambda like below but my syntax is incorrect. Result
I am trying to write a sql query like the example below, however, I
I'm trying to write sql that produces the desired result from the data below.
I'm trying to write a function to update the multiple select (the second one
I've been trying to write a Table-Valued function that takes value pairs as a
I'm trying to write a SQL Statement that should function like the below Linq
I'm trying to write a function that is the inverse of the function below.
I am trying to write a file in android using phonegap cordova 1.5.0. Below
I am trying to write a test case for the depot application. Below is
(In short: main()'s WaitForSingleObject hangs in the program below). I'm trying to write a

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.