Can not execute the MySQL query using PHP and MySQL -
i have issue when executing sql query.i explaining code below.
complain.php:
require_once("./include/dbconfig.php"); if($_request['typeofapp']=="web"){ $sent_form="web"; $ticket_id=generateticketid('w1'); } function generateticketid($code){ $sql="select * db_ticket order id desc "; $qrylast=mysqli_query($con,$sql); echo mysqli_num_rows($qrylast);exit; }
here trying check number of rows.but not getting anything.i giving dbconfig.php
below.
dbconfig.php
$con = new mysqli("localhost", "root", "****", "************"); if ($con->connect_error)die("connection failed: ");
here need check no of rows present inside table.please me.
you need define connection variable global have access in inside function or need pass in function parameter
require_once("./include/dbconfig.php"); //global $con; if($_request['typeofapp']=="web"){ $sent_form="web"; $ticket_id=generateticketid('w1',$con);// pass connection variable }
pass $con
variable parameter , function need return value
function generateticketid($code, $con) { $sql = "select * db_ticket order id desc "; $qrylast = mysqli_query($con, $sql); $rows = mysqli_num_rows($qrylast); if($rows>0){ return $rows; }else{ return false } }
Comments
Post a Comment