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

标签 php html mysql

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

相关文章:

java - Hibernate 很难使用 MySQL 创建表

php - 学说 1.2 性能,创造大量记录(~5000)

html - CSS:图像从 Bootstrap 面板中弹出

html - 如何使 2 个标题 block 响应并在图像前面也显示 <p>

html - Bootstrap 右栏动态高度

php - mysql真正的转义字符串不返回任何内容

PHP 和 MySQL SELECT 子字符串

php - 以编程方式删除 core_url_rewrite 条目 magento

javascript - 无法在 Angular 4 中通过 http.post() 发布变量

mysql - 如何转换这个(奇怪格式的)数据? :5:{s:15 :"nc_notification";s:1 :"2";s:20 :"iso_addToBook"