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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:39:19+00:00 2026-06-15T17:39:19+00:00

I am new to using PDO and I have no clue what is wrong

  • 0

I am new to using PDO and I have no clue what is wrong with it. It says i have this error
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING on line 3 Here is my code that goes along with it.

<?php
include 'dbconnect.php';
$sql = "INSERT INTO event (name,location,admission,map,additional,featured,description)    VALUES (:name,:location,:admission,:map,:additional,:featured,:description)";
$q = $conn->prepare($sql);
$q->execute(array(':name'=>$_POST['name'],
      ':location'=>$_POST['location'],
      ':admission'=>$_POST['addmission'],
      ':map'=>$_POST['map'],
      ':additional'=>$_POST['additional'],
      ':featured'=>$_POST['featured'],
      ':description'=>$_POST['description']));
?>
  • 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-15T17:39:20+00:00Added an answer on June 15, 2026 at 5:39 pm

    Remove the double quotes from all of these $_POST variables. There is no need to quote them, and indeed it causes harm if you also quote their array keys.

    $name= $_POST['name'];
    $location =  $_POST['location'];
    $admission =    $_POST['admission'];
    $map =   $_POST['map'];
    $additional  =  $_POST['additional'];
    $featured  =  $_POST['feature'];
    $description =   $_POST['description'];
    

    Inside a double-quoted string, if referencing array keys, you must not quote the keys, or surround the whole thing in {}. But neither is necessary here.

    echo "In a double quoted string, you can use $array[keys] unquoted, or surround quoted {$array['keys']} in {}";
    // But this is a syntax error! (like you are getting)
    echo "Don't quote the $array['keys'] if inside a double quote string, not wrapped in {}";
    

    In fact, there is no real need to assign them to variables at all. Just use the $_POST inputs directly in the execute() call.

    $q->execute(array(':name'=>$_POST['name'],
              ':location'=>$_POST['location'],
              ':admission'=>$_POST['addmission'],
              ':map'=>$_POST['map'],
              ':additional'=>$_POST['additional'],
              ':featured'=>$_POST['featured'],
              ':description'=>$_POST['description']));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

while using the following constructor $this->pdo = new PDO ($this->source, $this->username, $this->password); if I
I'm using this code and I'm beyond frustration: try { $dbh = new PDO('mysql:dbname='
Sorry if this is wrong or confusing I am very new to using classes
I am getting an error when updating a database using PDO. I am new
Using SQLite in PHP (thus using PDO), I have this code: try { $db
Well I just started using this new php PDO, and am having this issue.
I'm new to using PDO and prepared statement so if I'm doing this blatantly
I'm new to using PDO and have got a little bit stuck- is there
I have run into a problem using PDO because an error was not caught.
I am using PDO with PHP to create a new database and then 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.