drap5081683 2014-11-30 14:03
浏览 105

在我的脚本mysqli_query()中显示此错误:无法获取mysqli

<?php


session_start();


$hostname="localhost"; //local server name default localhost


$username="root";  //mysql username default is root.


$password="";       //blank if no password is set for mysql.

$database="bus-ticket-reservation"; //database name which you created

$con=mysqli_connect($hostname,$username,$password,$database);


 if(isset($_SESSION['id']))



{


include("config.php");



$uid = $_SESSION['id'];



$bus = $_GET['bus'];


$seat = $_GET['seat'];


$choice = $_GET['choice'];


$bust = $bus.'bus';


$date = date("Y-m-d"); 


 $query = mysqli_query($con,"Select * from bus where id ='$bus'");

 if($query){


    $re1 = mysqli_fetch_array($query);


        $bus_name = $re1['bus_name'];


        $from = $re1['from_stop'];


        $to = $re1['to_stop'];


        $dept_time = $re1['dept_time'];


        $arrival_time = $re1['arrival_time'];


        $distance = $re1['distance'];


        $fare = $re1['fare'];

}


    if($choice !='')


{


        if($choice=='W' && $seat==1)
{

$query2 = "Select * from $bust where status='Available' AND state='$choice' limit 0,$seat";

    $p = mysqli_query($con,$query2);


    $re = mysqli_num_rows($p);

        }


    else
        {

   $query2 = "Select * from $bust where status='Available' limit 0,$seat";

   $p = mysqli_query($con,$query2);

   $re = mysqli_num_rows($p);

}

   if($re>=$seat)
{

     while($r = mysqli_fetch_array($p))

{

     $id = $r['id'];

      $q3 = mysqli_query($con,"update $bust set status ='Booked' where id='$id'");

         $q4 = mysqli_query($con,"insert into user_history(user_id, bus_id,bus_name, from_stop , 

to_stop, booking_date, seat_no_booked, dept_time, distance, fare)

 values('".$uid."','".$bus."','".$bus_name."', '".$from."', '".$to."', '".$date."', '".$id."', 

'".$dept_time."', '".$distance."', '".$fare."')");

    }


?>
         <script>
  • 写回答

1条回答 默认 最新

  • dsbckxk165039 2014-11-30 14:25
    关注

    First of all, learn how to post questions. Second of all you tagged the question with "Python", this is php code.

    And not the best one of them either.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。