他,我正在尝试从一行中提取最大值以将其显示在警报消息中。但它给出了 2 个错误..
Warning: mysql_query() [function.mysql-query]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\wamp\www\test\test1.php on line 20
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\test\test1.php on line 20
请帮忙
<html>
<title> Test</title>
<head>
</head>
<body>
<form method="POST" action="">
<h1>Button to display data</h1>
<input type="submit" name="submit" value="PULL">
</form>
</body>
<?php
$no=20;
if(isset($_POST['submit']))
include ('airlineDB2.php');
{
$select=mysql_query("select MAX(ticketno) from ticketbook");
print '<script type="text/javascript">';
print 'alert("The no is '. $select.' is already registered")';
print '</script>';
}
?>
</html>
这是数据库的连接代码 我已将其另存为airlineDB2.php
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dberror1 = "Could not connect to database";
$link = mysql_connect($dbhost, $dbuser,$dbpass) or die ($drerror1);
$selectdb = mysql_select_db('airlinedb') or die ($drerror1);
?>
最佳答案
无法连接到数据库。您有一个拼写错误,因此您没有看到该错误:
$dberror1 = "Could not connect to database";
但稍后你会使用
$link = mysql_connect($dbhost, $dbuser,$dbpass) or die ($drerror1);
$dberror1 != $drerror1
关于php - 无法从数据库中提取并在 PHP 中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26886549/