• Register
0 votes
489 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'];
  }
.
.
.
7.5k points

Please log in or register to answer this question.

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.

38.6k points

Related questions

0 votes
1 answer 24 views
24 views
Problem: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound, but parameters are provided.Basically what I found out about this error is that it occurs when provided variables in bindParam are null, but $i is clearly not null. Can you help me out?
asked Apr 13 sumaiya simi 43.9k points
1 vote
1 answer 100 views
100 views
Problem: I&rsquo;m getting an error in the following code : // BUILD VALUES $count = count($matches); for($i = 0; $i < $count; ++$i) { $values[] = '(?)'; } // INSERT INTO DATABASE $q = $this -> dbc -> prepare("INSERT INTO hashes (hash) VALUES " . ... ) . " ON DUPLICATE KEY UPDATE hash = hash"); $q -> execute($matches);The error : SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
asked May 3 Raj Tyagi 16k points
0 votes
1 answer 79 views
79 views
Problem: invalid parameter number: parameter was not defined
asked Feb 14 Sabbir Hossain 14.6k points
0 votes
1 answer 5 views
5 views
Problem : Invalid parameter number no parameters were bound
asked Jun 29 Siam55 110k points
0 votes
0 answers 6 views
6 views
Problem: Hi can some one help me outwith this issue? column count doesn't match value count
asked Mar 20 PkGuy 25.9k points
0 votes
1 answer 65 views
65 views
Problem: Here is the link to the table and detailed description of question 11 on SQLZOO Join: sqlzoo.net/wiki/The_JOIN_operation. The question is asking 'For every match involving 'POL', show the matchid, date and the number of goals scored.' Below is my SQL code SELECT ... why here I have to group by both matchid and mdate instead of just one of them? Thank you in advance for your kind help.
asked Apr 25 muktaa 34.6k points
0 votes
1 answer 97 views
97 views
Problem column name or number of supplied values does not match table definition
asked Feb 9 charles mathews 5.5k points
0 votes
1 answer 9 views
9 views
Problem: Please,I want an answer : The log sequence number in ibdata files does not match
asked Jun 26 Sawyer Parviz 167k points
0 votes
1 answer 716 views