mysql - Getting error on executing prepared statement in PHP -
i have code follows giving me error on prepared statement line:
homepage.php
<html> <head> </head> <body> <ul id="list"> <li><h3><a href="#">tops</a></h3></li> <li><h3><a href="#">suits</a></h3></li> <li><h3><a href="#">jeans</a></h3></li> <li><h3><a href="newpage.php?name=women">more</a></h3></li> </ul> </body> </html>
newpage.php
<?php $mysqli = new mysqli('localhost', 'root', '', 'shop'); if(mysqli_connect_errno()) { echo "connection failed: " . mysqli_connect_errno(); } ?> <html> <head> </head> <body> <?php session_start(); $lcsearchval=$_get['name']; //echo "hi"; $lcsearcharr=explode("-",$lcsearchval); $result=count($lcsearchval); //echo $result; $parts = array(); $parts1=array(); foreach( $lcsearcharr $lcsearchword ){ $parts[] = '`pname` "%'.mysqli_real_escape_string($lcsearchword).'%"'; $parts1[] = '`tags` "%'.$lcsearchword.'%"'; //$parts[] = '`category` "%'.$lcsearchword.'%"'; } $stmt = $mysqli->prepare("select * xml ('.implode ('and',?).')"); $stmt->bind_param("s",$parts); $list=array(); if ($stmt->execute()) { while ($row = $stmt->fetch()) { $list[]=$row; } } $stmt->close(); $mysqli->close(); foreach($list $array) { ?> <div class="image"> <img src="<?php echo $array['imageurl']?>" width="200px" height="200px"/></a> <?php } ?> </div> </body> </html>
sql query in php file not getting executed. i'm getting following error:
mysqli_stmt::bind_param(): number of variables doesn't match number of parameters in prepared statement
i not able correct error, have tried lot.
change
$parts[] = '`pname` "%'.mysql_real_escape_string($lcsearchword).'%"';
to
$parts[] = '`pname` "%'.mysqli_real_escape_string($lcsearchword).'%"';
Comments
Post a Comment