Hello, I'm trying to get the courses from the database. To see the courses already registered, do not register in db again. I'm getting this error:
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /storage/emulated/0/Documents/sistemaescolar/public/cad/curso.php on line 6
the connection code
$host="127.0.0.1"; $db="sistemaescolar"; $pswd=""; $user="root"; $connect = mysqli_connect ($host,$user,$pswd,$db); if (mysqli_connect_errno()){ echo "Failed to connect to MySQL: " . mysqli_connect_error(); }
I made this page below to decide what type will become of cadatro, coming from another form:
include_once "class_pessoa.php"; if(isset($_POST["buttonSubmit"])){ $escolha = filter_input(INPUT_POST,'opselect',FILTER_SANITIZE_NUMBER_INT); if(filter_var($escolha,FILTER_VALIDATE_INT)){ include_once "cad/conexao.php"; $sql = "SELECT * from tipoCad where id=$escolha"; $resultado = mysqli_query($connect,$sql); $dado= mysqli_fetch_assoc($resultado); if($dado["nome"] =="Curso"){ $curso = new Curso($dado["nome"]); } mysqli_close($connect); } }
In the part where you have the class Travel, you have a form to be able to register in db
Below is the code that is giving error when searching the database:
$sql = "select * from cursos"; $resultado=mysqli_query($connect,$sql); while($dados= mysqli_fetch_assoc($resultado)){ echo $dados['nome']; }