Undefined constants

Someone tell me why I get the messages below?

Notice: Use of undefined constant localhost - assumed ‘localhost’ in C:\xampp\htdocs\hofiles\maintupdate.php on line 2

Notice: Use of undefined constant root - assumed ‘root’ in C:\xampp\htdocs\hofiles\maintupdate.php on line 2

Notice: Use of undefined constant maintdb - assumed ‘maintdb’ in C:\xampp\htdocs\hofiles\maintupdate.php on line 3

<?php  
mysql_connect("localhost","root",""); 
mysql_select_db('maintdb') or die( "Unable to select database"); 
if(!empty($_POST["submit"])) 
{ 
 $apt = $_POST['apt']; 
 $query="SELECT * FROM maintdata Where apt='$apt'"; 
 $result=mysql_query($query); 

Usually this error happens when you don’t have quotes around the variables.

Does your code look exactly like you posted it, or is it more like this:


<?php   
mysql_connect(localhost,"root","");  
mysql_select_db(maintdb) or die( "Unable to select database");  
// etc...

exactly as I posted. a couple of months ago, it worked without the messages without the quotes? Since I started to get the messages in all my programs I added the quotes per suggestions?

Probably because you had “Notice” errors turned off.