i am making a cms for a school assiment but when i try to create a new category it keeps giving me errors: google chrome gives me this:
Warning: mysqli_query() expects parameter 1 to be mysqli, string given
in Warning: Missing argument 3 for addCat(), called in
C:xampphtdocsportfoliojbehrensadmindoAddc.php on line 6 and
defined in C:xampphtdocsportfoliojbehrensincludesfunctions.php on
line 254
Notice: Undefined variable: cDesc in
C:xampphtdocsportfoliojbehrensincludesfunctions.php on line 255
Warning: mysqli_query() expects parameter 1 to be mysqli, string given
in C:xampphtdocsportfoliojbehrensincludesfunctions.php on line
256
Warning: Cannot modify header information - headers already sent by
(output started at
C:xampphtdocsportfoliojbehrensincludesfunctions.php:254) in
C:xampphtdocsportfoliojbehrensadmindoAddc.php on line 7
here is my code:
from the function page:
function addCat($mysqli, $cName, $cDesc){
$query = "INSERT INTO categories (title, description) VALUES ('$cName', '$cDesc')";
mysqli_query($mysqli, $query);
}
from the page that shout check the inputs:
<?php
include '../includes/functions.php';
sec_session_start();
if(isset($_POST['submit'])){
if(isset($_POST['CatName'])){
addCat($_POST['CatName'],$_POST['CatDesc']);
header("Location: categories.php");
} else{
echo"please set a category name!";
include('addCat.php');
}
}else{
header("Location: addCat.php");
}
?>
and finally the input:
<form action="doAddc.php" method="post">
<label for="CatName">Name</label>
<input type="text" name="CatName" id="CatName"/>
<label for="CatDesc">Description</label>
<input type="text" name="CatDesc" id="CatDesc"/>
<input type="submit" name="submit" value="submit"/>
</form>
hope some of u know what i am doing wrong here
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…