• Register
0 votes
150 views

Problem :

I am facing the error as SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 102 in comments.php below:

<?php
/**
 * Class to handle the articles
 */
class Comment
{
  // The Properties
  /**
  * @var int The article ID from your database
  */
  public $id = null;
  /**
  * @var int When your article is to be / was first published
  */
  public $publicationDate = null;
  /**
  * @var string Full title of your article
  */
  public $title = null;
  /**
  * @var string The HTML content of your article
  */
  public $content = null;
    /**
     * @var int The article ID from your database
     */
    public $articleid = null;
  /**
  * Sets the object's properties using your values in the supplied array
  *
  * @param assoc your property values
  */
  public function __construct( $data=array() ) {
    if ( isset( $data['id'] ) ) $this->id = (int) $data['id'];
    if ( isset( $data['publicationDate'] ) ) $this->publicationDate = (int) $data['publicationDate'];
    if ( isset( $data['title'] ) ) $this->title = preg_replace ( "/[^\.\,\-\_\'\"\@\?\!\:\$ a-zA-Z0-9()]/", "", $data['title'] );
    if ( isset( $data['content'] ) ) $this->content = $data['content'];
      if ( isset( $data['articleid'] ) ) $this->articleid = (int) $data['articleid'];
  }
.
.
.
6 5 3
7,540 points

1 Answer

0 votes

Solution :

Probably you did not bind all your bindings as below

$sql = "SELECT SQL_CALC_FOUND_ROWS *, UNIX_TIMESTAMP(publicationDate) AS publicationDate     FROM comments WHERE articleid = :art 
ORDER BY " . mysqli_escape_string($order) . " LIMIT :numRows";
$st = $conn->prepare( $sql );
$st->bindValue( ":art", $art, PDO::PARAM_INT );

So You have just declared the binding called :numRows but you never actually bind anything to it.

9 7 4
38,600 points

Related questions

0 votes
1 answer 9 views
9 views
I have a dropdown elements based on the select option. I want to experiment on how make the selection using ajax. For example, I have this list: <select name="search" id="search"> <option>John Doe</option> <option>Gary Riley</option> <option>Edward Siu</option> </select> < ... "> <input type="text" id="phone"> And I want to display the email address and phone number. How can I do this using ajax?
asked 1 day ago RJ Lam 180 points
0 votes
1 answer 18 views
0 votes
1 answer 53 views
53 views
Problem : I am trying to import mySql database which was originally an access database into phpmyadmin and its giving me following error: incorrect table definition; there can be only one auto column and it must be defined as a key
asked Nov 14, 2019 peterlaw 6.9k points