PHP连接,查询正常,但显示错误. [英] PHP connection, query working but showing error.

查看:84
本文介绍了PHP连接,查询正常,但显示错误.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!
我正在使查询正常运行,但是我不知道查询结果上方的通知消息!

注意:使用未定义的常量admin-在第13行的C:\ xampp \ htdocs \ test \ mysql.php中假定为"admin"
共找到1条记录.


我在网站上使用了两个不同的页面:

connection.inc.php

Hi Guys !
I am getting my query working but i dont know a Notice message on top on query result !

Notice: Use of undefined constant admin - assumed ''admin'' in C:\xampp\htdocs\test\mysql.php on line 13
A total of 1 records were found.


I am using two diffent pages for my web are:

connection.inc.php

<?php
function dbConnect($type) {
if ($type == 'query') {
$user = 'globalluser';
$pwd = 'member';
}
elseif ($type == 'admin') {
$user = 'globalladmin';
$pwd = 'essendon';
}
else {
exit('Unrecognized connection type');
}
// Connection code goes here

    $mysql_host = 'localhost';
    $mysql_user = 'globalladmin';
    $mysql_pass = 'essendon';

    $mysql_db = 'globall';

if (!mysql_connect($mysql_host, $mysql_user, $mysql_pass) || !mysql_select_db($mysql_db)){
die(mysql_error());
}
}

?>





mysql.php





mysql.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>data </title>
</head>
<body>
<?php



include 'connection.inc.php';



// connect to MySQL

$conn = dbConnect(admin);



// prepare the SQL query

$sql = 'SELECT * FROM customer';



// submit the query and capture the result

$result = mysql_query($sql) or die(mysql_error());



// find out how many records were retrieved

$numRows = mysql_num_rows($result);

?>

<p>A total of <?php echo $numRows; ?> records were found.</p>



</body>
</html>

推荐答案

type){ 如果(


type == '
type == 'query') {


user = '
user = 'globalluser';


这篇关于PHP连接,查询正常,但显示错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆