Hello Friends,
i return a database connectivity like this.
function db_conn()
{
$mysqli = new mysqli("localhost", "root", "", "test");
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
return $mysqli;
}
with this upto now i used to insert records successfully. but now i have an problem with Delete and Update records.
the query i retrurned to delete records
if(!empty($_POST['del_btn']) && $_POST['del_btn'] == 'Delete')
{
$delids = explode('`#`',$_POST[delid]);
for($x=0;$x<count($delids);$x++)
{
if(isset($_POST['del_'.$delids[$x]]) && $_POST['del_'.$delids[$x]]!='')
{
// mysqli_query($mysqli, "DELETE FROM resource_tasks where id=".$delids);
//printf("Affected rows (DELETE): %d\n", mysqli_affected_rows($link));
$dquery = "delete from resource_tasks where id=".$delids;
//echo $dquery;exit;
$dresp = mysqli_query($dquery);
//printf("Affected rows (DELETE): %d\n", mysqli_affected_rows($mysqli)); exit;
$affecrows = mysqli_affected_rows($dquery);
}//end of if
//onClick="alert(document.form1.length);"
}///end of for
echo $affecrows;exit;
//if($affecrows > 0)
if($dresp)
{
echo '<META HTTP-EQUIV="REFRESH" CONTENT="0;URL=report_form.php?res=1">';
exit;
}
else
{
echo '<META HTTP-EQUIV="REFRESH" CONTENT="0;URL=report_form.php?res=2">';
exit;
}
}
but it showing warnings like this
Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\xampp\htdocs\mis\timesheets\report.php on line 16
Warning: mysqli_affected_rows() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs\mis\timesheets\report.php on line 18
so plz can anybody help on this soon.