Page 1 of 1

if else statement error

Posted: Sun Nov 07, 2010 12:35 pm
by lord
why does this not work? I cannot figure out what is wrong?

What I am trying to do is if there are no seats available then not to insert anything into the database...

Code: Select all


		<?php
			

			if($seat != '0')
			{	
			
				$sql="INSERT INTO demonstrations (umid, fname, lname, project_title, email, phone, time_slot)
				VALUES
				('$_POST[umid]','$_POST[fname]','$_POST[lname]','$_POST[project_title]','$_POST[email]','$_POST[phone]','$_POST[time_slot]' )";

				if (!mysql_query($sql,$con))
				{
					die('Error: ' . mysql_error());
				}

				$result = mysql_query("SELECT * from demonstrations");
				while($row = mysql_fetch_array($result))
				{
					echo $row['umid'] . " " . $row['fname'] . " " . $row['lname'] . " " . $row['project_title'] . " " . $row['email'] . " " . $row['phone'] . " " . $row['time_slot']  ;
					echo "<br />";
				}
			
			mysql__close($con)
			}
			
			else
			{
				mysql__close($con);	
			}




Re: if else statement error

Posted: Sun Nov 07, 2010 12:49 pm
by dk4210
What does it insert in the db?

Re: if else statement error

Posted: Sun Nov 07, 2010 2:43 pm
by DigitalMind
it's difficult to say because of your poor description.
maybe

Code: Select all

if ($seat)