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

  • Home
  • SEARCH
  • 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 9148261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:13:33+00:00 2026-06-17T11:13:33+00:00

$sql = $db->prepare(INSERT INTO users (user_username, user_password, user_email) VALUES ($username, $password, $email)); $sql->bindParam(‘:user_name’, $username);

  • 0
    $sql = $db->prepare("INSERT INTO users (user_username, user_password, user_email) VALUES ($username, $password, $email)");
    $sql->bindParam(':user_name', $username);
    $sql->bindParam(':user_password', $password);
    $sql->bindParam(':user_email', $email);
    $sql->execute();

I’m trying to learn PDO rather than using mysql_ but I’m running into a problem. This doesn’t seem to be inserting and I’m not sure why.

I’m not getting any error messages either so I don’t know what to Google.

Also, is the $db variable being in an included file (config.php which has all the database details) a problem?

  • 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-17T11:13:34+00:00Added an answer on June 17, 2026 at 11:13 am

    First thing’s first, when you’re developing turn on error reporting so you can see any error messages.

    $db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
    

    Executing the code you have should be producing some sort of error because you are trying to bind to parameters that don’t exist. Named parameters need to start with a : or if you would just prefer placeholder type parameters, you can use ? instead. When you do:

    ...VALUES ($username, $password, $email)"
    

    The variables will be parsed into their actual values:

    ...VALUES (bob, $2y$14$youarehashingpasswordsright, bob@gmail.com)"
    

    which of course, would be a syntax error in your SQL. Instead, you need to put their parameter names:

    ......VALUES ( :username , :password , :email )"
    

    Then if that doesn’t work, look at any errors being produced and make sure the queries are actually being committed.

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

Sidebar

Related Questions

I have the following Query : INSERT INTO users (user_id, date_created) VALUES (?,?) I
I'm trying to execute a prepared sql request wich should insert values into a
I have an SQL query that goes like this: $stmt = $dbh->prepare(INSERT INTO Places
I am new to iphone development.I want to insert multiple values into my sqlite3
We are inserting values into a SQL Server 2005 database column of type NUMERIC(19,5)
Ok so i want to do a prepared insert such as: prepare(INSERT INTO `analyzeditemsdetails`
I'm doing SQL queries in prepared statements(MySQLi) This is the query $register = $friend_zone->prepare(INSERT
im doing some practice sql problems one of the questions is: Prepare a shipping
Using DBI::DatabaseHandle#execute or DBI::DatabaseHandle#prepare it's not possible to run an sql script (with mutiple
I am customizing the insert SQL generated by hibernate and have hit an issue.

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.