• Register
0 votes
209 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 235 views
0 votes
2 answers 50 views
50 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 Oct 26, 2020 RJ Lam 650 points
0 votes
1 answer 39 views
0 votes
1 answer 67 views
67 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
0 votes
1 answer 25 views
25 views
Problem: Hi, I am new to php database operations. i have written the query and it shows the error column count doesn't match value count at row 1 mysql. INSERT INTO Student VALUES ('Name', 'last name''class');
asked Nov 16, 2020 prog_learner 2.5k points
0 votes
1 answer 18 views
18 views
Hello Kodlogs, I was trying to access my database using PHP code. The code snippets I included below shows my code. This code should be able to display the my station name. But I got a an error: &lsquo;mysqli_num_rows() expects parameter 1 to be mysqli_result&rsquo;. $query ... my head on this because I can&rsquo;t see any problem with my code. So I hoped that you could help me. Thank you!
asked Oct 11, 2020 dorothy 300 points
1 vote
1 answer 300 views
300 views
Problem : I am beginner to CodeIgniter, If I try to execute my code then I face below error Object of class ci_db_mysqli_result could not be converted to string . Please find below my code for your reference. class MyReg extends CI_Controller{     function __construct(){ ... my above query in my model but I often face above error. I am looking for CodeIgniter experts help in fixing above error.
asked Apr 21, 2020 stewart 4k points
0 votes
2 answers 93 views
93 views
Problem: I am new, I need help, can anyone help me by filling in the blanks? The ____ function determines the lowest number in a range?
asked Feb 19, 2020 maddi86 5.4k points
0 votes
1 answer 28 views