I'm new to PHP and I'm some trouble writing to multiple tables from the same form. When I run the following script it will not write the data to XINFO but it will write to ATTRIB1. If I take ATTRIB1 out of the script it will work properly and once again write to XINFO. I can't figure out what I'm doing wrong. Any help would be greatly appreciated.

// Insert fields into XINFO 
	 $sql = "INSERT INTO xinfo SET
	 
first_name='$fn',
last_name='$ln',
city='$city',
state_province='$state',
country='$cntry',
other_country='$ocntry',
dob='$dob',
email='$em' ";

// Insert fields into ATTRIB1
	$sql = "INSERT INTO attrib1 
	
example='$x1' ";

Recommended Answers

All 2 Replies

You are overwriting your $sql variable with the second statement. Try running the first SQL statement before you set the $sql variable, or you could change your second statement to use a new variable, for example $sql2.

Thanks darkagn. A quick $exec = mysql_query() between statements did the trick.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.