• Register
0 votes
283 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

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.

9 7 4
38,600 points

Related questions

0 votes
1 answer 16 views
16 views
Problem: invalid parameter number: parameter was not defined
asked Feb 14 Shovo210 13.3k points
0 votes
0 answers 2 views
2 views
Problem: Hi can some one help me outwith this issue? column count doesn't match value count
asked Mar 20 PkGuy 13.1k points
0 votes
1 answer 21 views
21 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 411 views
0 votes
1 answer 2 views
2 views
Problem: I need assistance in resolving this problem: &ldquo;Multiple variables can be created and initialized in a single javascript statement&rdquo;?
asked Mar 30 tuhin1 48.4k points
0 votes
1 answer 3 views
3 views
Problem: The requirement is that if I have a site_id as an input, and I need all the ids tagged below the site. I need the best-optimized technique within my data model constraint. Feel free to answer if you have any suggestions. Please suggest anything. Thanks in advance.
asked 3 days ago ummesalma 24.5k points
0 votes
0 answers 7 views
7 views
Problem: What are my options for resolving this problem &ldquo;How to fetch data from database in php using ajax with example&rdquo;?
asked Mar 29 tuhin1 48.4k points
1 vote
1 answer 3 views
3 views
Problem: Any solution to this error? Securityerror: error #2060: security sandbox violation.
asked Mar 28 PkGuy 13.1k points
1 vote
1 answer 3 views
3 views
Problem : Why I'm getting the following errors : Fatal error: Call to a member function query() on null in C:\xampp\htdocs\wisconsindairyfarmers\admin\login.php on line 7 Any ideas on what I need to do to fix this? Thanks!
asked Mar 27 Shovo210 13.3k points