gpt4 book ai didi

php - 无法从数据库中提取并在 PHP 中显示

转载 作者:行者123 更新时间:2023-11-29 23:26:54 25 4
gpt4 key购买 nike

他,我正在尝试从一行中提取最大值以将其显示在警报消息中。但它给出了 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com