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

时间:2014-11-12 12:02:56

标签: 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);
?>

2 个答案:

答案 0 :(得分:0)

与数据库的连接不起作用。你有一个错字,这就是为什么你没有看到错误:

$dberror1 = "Could not connect to database";

但稍后使用

$link = mysql_connect($dbhost, $dbuser,$dbpass) or die ($drerror1);

$ dberror1 != $ drerror1

答案 1 :(得分:0)

<?php 
$no=20;
if(isset($_POST['submit']))
include ('airlineDB2.php');
{

在大括号之后制作包含