Why SQL Expect Parameter to be Integer and mysqli?
Why SQL Expect Parameter to be Integer and mysqli?
I got 2 warnings.
First :
mysqli_connect() expects parameter 5 to be integer, string given in C:xampphtdocsadminconfigkoneksi.php on line 11
mysqli_connect() expects parameter 5 to be integer, string given in C:xampphtdocsadminconfigkoneksi.php on line 11
My line 11 is
$koneksi = mysqli_connect($server, $id_user, $nama, $username, $password, $level);
Second :
mysqli_select_db() expects parameter 1 to be mysqli, null given in C:xampphtdocsadminconfigkoneksi.php on line 12
mysqli_select_db() expects parameter 1 to be mysqli, null given in C:xampphtdocsadminconfigkoneksi.php on line 12
My line 12 is
$selected = mysqli_select_db($koneksi, $database) or die("Couldn't open database $database");
Full Code
<?php
$server = "localhost";
$id_user = "";
$nama = "";
$username = "root";
$password = "";
$level = "";
$database = "penjualan";
$koneksi = mysqli_connect($server, $id_user, $nama, $username, $password, $level);
$selected = mysqli_select_db($koneksi, $database) or die("Couldn't open database $database");
?>
Im using PHP 7. Thanks for any help.
Additional Info
my check_login.php file that connected to the connection.php
<?php
include "../config/koneksi.php";
function antiinjection($data)
$filter_sql = mysqli_real_escape_string(stripslashes(strip_tags(htmlspecialchars($data,ENT_QUOTES))));
return $filter_sql;
$id_user = mysqli_real_escape_string($koneksi, $_POST['id_user']);
$nama = mysqli_real_escape_string($koneksi, $_POST['nama']);
$username = mysqli_real_escape_string($koneksi, $_POST['username']);
$password = mysqli_real_escape_string($koneksi, $_POST['password']);
$level = mysqli_real_escape_string($koneksi, $_POST['level']);
$login = mysqli_query($koneksi,"SELECT * FROM user WHERE id_user='$id_user' AND nama='$nama' AND username='$username' AND password='$password' AND blokir='N'");
$ketemu = mysqli_num_rows($login);
$r = mysqli_fetch_assoc($login);
if ($ketemu > 0)
session_start();
session_register("id_user");
session_register("namauser");
session_register("passuser");
session_register("leveluser");
$_SESSION[id_auser] = $r[id_name];
$_SESSION[namauser] = $r[username];
$_SESSION[passuser] = $r[password];
$_SESSION[leveluser] = $r[level];
header('location:media.php?module=home');
else
echo "<link href=style.css rel=stylesheet type=text/css>";
echo "<center>LOGIN GAGAL!<br>
Username atau Password Anda tidak benar<br>
Atau account Anda sedang diblokir<br>";
echo "<a href=index.php><b>ULANGI LAGI</b></a></center>";
?>
1 Answer
1
I think you are passing the wrong parameters.
this is correct way how the parameters should be passed.
mysqli_connect(host,username,password,dbname,port,socket);
so in your case i think it should be
mysqli_connect($server,$username,$password,$database);
in which line ?
– Kanishka Panamaldeniya
Sep 2 at 6:23
Additional Info Code, line 8,9,12
– abw1904
Sep 2 at 6:39
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
It makes Undefined Index
– abw1904
Sep 2 at 6:12