Notice: Undefined variable:

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mark anthony
    New Member
    • Mar 2011
    • 1

    #1

    Notice: Undefined variable:

    Code:
    <?php
    	mysql_connect('localhost','root','')or die(mysql_error());
    	mysql_select_db('goldas')or die(mysql_error());
    
    	
    	if(isset($_POST['S1']))
    	{
    		$a1 = $_POST['t1'];
    		$a2 = $_POST['t2'];
    		$a3 = $_POST['t3'];
    		$a4 = $_POST['t4'];
    		$a5 = $_POST['t5'];
    	}
    		$q="INSERT INTO customer VALUES('','$a1','$a2','$a3','$a4','$a5')";
    		mysql_query($q) or die(mysql_error());
    		
    
    ?>
    Undefined variable a1,a2,a3,a4,a5
    Can u tell me where is the wrong??
    Last edited by Dormilich; Mar 12 '11, 06:20 AM. Reason: please use [CODE] [/CODE] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you have the variables’ definition outside the $_POST check

    Comment

    Working...