0

I am having trouble understanding the error. what is wrong with the code? I have a database named "test" so I am not expected to define test like $test.

HTML code:

<html>
<head><title>SOmething</title></head>
<body>
   <form name="fm" method="POST" action="cafe.php">
      Customer ID:<input type="text" name="cus"><br>
      Food Name:<input type="text" name="food"><br>
      Order ID:<input type="text" name="order"><br>
   </form>
</body>
</html>

PHP code:

<?php
$isMySQLConnected=mysql_connect("localhost","root");

if($isMySQLConnected){
    echo "We are Connected to MySQL<br>"; 
}

$isDBConnected=mysql_select_db(test);

if($isDBConnected){
    echo "We are Connected to Test DataBase"; 
}

$cus=$_POST['cus'];
$food=$_POST['food'];
$order=$_POST['order'];
?>

Error:

We are Connected to MySQL

Notice: Use of undefined constant test - assumed 'test' in C:\xampp\htdocs\assign\cafe.php on line 6 We are Connected to Test DataBase

Notice: Undefined index: cus in C:\xampp\htdocs\assign\cafe.php on line 10

Notice: Undefined index: food in C:\xampp\htdocs\assign\cafe.php on line 11

Notice: Undefined index: order in C:\xampp\htdocs\assign\cafe.php on line 12

Anh Pham
  • 2,108
  • 9
  • 18
  • 29

0 Answers0