<?php
$db_server_nm = "localhost:3306";
$db_user_name = "root";
$db_password = "root";
$db_name = "cacs";
// create connection
$connection = mysqli_connect($db_server_nm, $db_user_name, $db_password, $db_name);
// checking connection
if ( ! $connection){
die('Cannot be Connected :'.mysqli_connect_error($connection));
}
echo ("Connected to database<br>");
/*
$user_nm = $_POST['User Name'];
$pwd = $_POST['Password'];
echo ("User:- " .$db_user_name ." and PWD :-" .$db_password . "<br>");
*/
$sql_android_metadata = "SELECT * FROM `android_metadata`";
$sql_chapter = "SELECT * FROM `chapter`";
$sql_course = "SELECT * FROM `course`";
$sql_cpt_part1 = "SELECT * FROM `cpt_part1`";
$sql_question = "SELECT * FROM `questions`";
$sql_exam = "SELECT * FROM `exam`";
$sql_exercie = "SELECT * FROM `exercise`";
$sql_paper = "SELECT * FROM `paper`";
$sql_resultdisplay = "SELECT * FROM `resultdisplay`";
$sql_section = "SELECT * FROM `section`";
$sql_subject = "SELECT * FROM `subject`";
$sql_test_of_cpt = "SELECT * FROM `test_of_cpt`";
$sql_test_of_ipcc = "SELECT * FROM `test_of_ipcc`";
$res_am = mysqli_query($connection, $sql_android_metadata);
$row = mysqli_fetch_array($res_am);
$res_chap = mysqli_query($connection, $sql_chapter);
$row = mysqli_fetch_array($res_chap);
$res_course = mysqli_query($connection, $sql_course);
$row = mysqli_fetch_array($res_course);
$res_cpp1 = mysqli_query($connection, $sql_cpt_part1);
$row = mysqli_fetch_array($res_cpp1);
$res_ques = mysqli_query($connection, $sql_question);
$row = mysqli_fetch_array($res_ques);
$res_exer = mysqli_query($connection, $sql_exercie);
$row = mysqli_fetch_array($res_exer);
$res_paper = mysqli_query($connection, $sql_paper);
$row = mysqli_fetch_array($res_paper);
$res_resdisp = mysqli_query($connection, $sql_resultdisplay);
$row = mysqli_fetch_array($res_resdisp);
$res_sect = mysqli_query($connection, $sql_section);
$row = mysqli_fetch_array($res_sect);
$res_sub = mysqli_query($connection, $sql_subject);
$row = mysqli_fetch_array($res_sub);
$res_test_cpt = mysqli_query($connection, $sql_test_of_cpt);
$row = mysqli_fetch_array($res_test_cpt);
$res_test_ipcc= mysqli_query($connection, $sql_test_of_ipcc);
$row = mysqli_fetch_array($res_test_ipcc);
//$data=$row[0];
if(! ($res_am || $res_chap || $res_course || $res_cpp1 || $res_ques || $res_exer || $res_paper
|| $res_resdisp || $res_sect || $res_sub || $res_test_cpt || $test_of_ipcc)){
die ('Data cannot be retrieved:'. mysqli_error($connection)); }
echo "<br> Data retrieved Successfully";
$connection-> close();
?>
收到此错误...
但是当我将mysqli_connect()更改为新的msqli时,它可以工作。使用的方法或其他方面是否有任何问题。 请帮助我
答案 0 :(得分:0)
PHP doc for msqli_connect/__construct表示端口应该是第5个参数。严格地说,这意味着第一个参数应该是localhost
(而不是localhost:3306
),第五个参数应该是3306
)。也许msqli_connect
强制执行此操作,而new
则不执行此操作。值得一试。