Click here to Skip to main content
14,698,806 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am working on the dbconn of the admin but its brings errors everytime i try to change something.
Plz help.

What I have tried:

<?php
$host="localhost";
$uname="root";
$pas="";
$db_name="cman";
$tbl_name="admin";

$link = mysqli_connect("$host","$uname","$pas") or die ("cannot connect");
bool mysqli_select_db( mysqli $link, string $db_name);
?>
Posted
Updated 30-Sep-20 6:59am
Comments
Member 13761917 4-Apr-18 7:02am
   
thanks this has worked for me though i cannot login to my page as an admin

the page just freshes itself, no errors

This is my login.php file

<?php
$host="localhost";
$uname="root";
$pas="";
$db_name="cman";
$tbl_name="members";

$link = mysqli_connect($host, $uname, $pas, $db_name) or die ("cannot connect");
$select_db_result = mysqli_select_db($link, $db_name);
?>
<?php
if (isset($_POST['login'])){

$username=$_POST['username'];
$password=$_POST['password'];

$login_query=mysqli_query("select * from members where mobile='$username' and password='$password'");
$count=mysqli_num_rows($login_query);
$row=mysqli_fetch_array($login_query);


if ($count > 0){
session_start();
$_SESSION['id']=$row['id'];
header('location:members/dashboard.php');

}else{
header('location:index.php');
}
}
?>

what do u think could be the problem?

Have a look at the line from the error message:
bool mysqli_select_db( mysqli $link, string $db_name);
That is not a valid PHP statement. It looks like you have copied the PHP: mysqli::select_db - Manual[^] function definition.

To use such functions, remove the types and replace the arguments with existing variables:
$select_db_result = mysqli_select_db($link, $db_name);

But there is even no need to call mysqli_select_db() because you can pass the database name also when connecting (as prominently noted in the above link):
$link = mysqli_connect($host, $uname, $pas, $db_name) or die ("cannot connect");
Note that I have correct the parameters to mysqli_connect() here too because the passed variables contain already the required data and creating a duplicate string is not necessary (the string created with "$host" is effectively the same as $host here).
   
Parse error: syntax error, unexpected 'col' (T_STRING) in C:\xampp2\htdocs\tutorial\shopping\php\components.php on line 6
   
Comments
Richard Deeming 30-Sep-20 12:55pm
   
Your error message is not a "solution" to someone else's question.

Since you haven't provided any details, it's not even a question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900