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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:21:51+00:00 2026-05-27T01:21:51+00:00

I believe I have the syntax correct, at least according to my textbook. This

  • 0

I believe I have the syntax correct, at least according to my textbook. This is just a piece of the file as the other info is irrelevant to my problem. The table name is user, as well as the column name is user. I don’t believe this to be the problem, as other sql statements work. Though it isn’t the smartest thing to do I know 🙂 Anyone see an error?

try {
$db=new PDO("mysql:host=$db_host;dbname=$db_name",
        $db_user,$db_pass);
} catch (PDOException $e) {
exit("Error connecting to database: " . $e->getMessage());
}
$user=$_SESSION["user"];

$pickselect = "SELECT game1 FROM user WHERE user='$user' ";
$pickedyet = $db->prepare($pickselect);
$pickedyet->execute();
echo $pickselect;

if ($pickedyet == "0")
{ 
echo '<form method="post" action="makepicks.php">
<h2>Game 1</h2>......'
  • 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-27T01:21:51+00:00Added an answer on May 27, 2026 at 1:21 am

    Since you’re seemingly using prepared statements, I’d recommend using them to their fullest extent so that you can avoid traditional problems like SQL injection (this is when someone passes malicious SQL code to your application, it’s partially avoided by cleansing user inputs and/or using bound prepared statements).

    Beyond that, you’ve got to actually fetch the results of your query in order to display them (assuming that’s your goal). PHP has very strong documentation with good examples. Here are some links: fetchAll; prepare; bindParam.

    Here is an example:

    try
    {
        $db = new PDO("mysql:host=$db_host;dbname=$db_name",
                      $db_user, $db_pass);
    }
    catch (PDOException $e)
    {
        exit('Error connecting to database: ' . $e->getMessage());
    }
    
    $user = $_SESSION['user'];
    
    $pickedyet = $db->prepare('SELECT game1 FROM user WHERE user = :user');
    /* Bind the parameter :user using bindParam - no need for quotes */
    $pickedyet->bindParam(':user', $user);
    $pickedyet->execute();
    
    /* fetchAll used for example, you may want to just fetch one row (see fetch) */
    $results = $pickedyet->fetchAll(PDO::FETCH_ASSOC);
    
    /* Dump the $results variable, which should be a multi-dimensional array */
    
    var_dump($results);
    

    EDIT – I’m also assuming that there is a table called ‘user’ with a column called ‘user’ and another column called ‘game1’ (i.e. that your SQL statement is correct aside from the usage of bound parameters).

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

Sidebar

Related Questions

Although I'm doing this in cakephp, i believe I have a terrible php-syntax-newbie-mistake in
I want to print from a servlet. I believe I have the correct syntax.
This is staight forward I believe: I have a table with 30,000 rows. When
I believe this question might have been previously attempted in 2006 on a different
Forgive me if this has already been asked elsewhere. I have a Scala syntax
I'm playing with MVC3 using the Razer syntax, though I believe the problem to
I believe this is an AutoMapper basics question: I have an single article Entity
I believe I have a syntax error, but I have tried everything and can't
I have a problem that I believe I need to use grouping using xsl:key
I believe I have disabled the view state on all controls as well as

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.