if else statement error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lord
Forum Newbie
Posts: 5
Joined: Sun Nov 07, 2010 12:30 pm

if else statement error

Post 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);	
			}



dk4210
Forum Newbie
Posts: 9
Joined: Sat Jul 30, 2005 12:06 pm

Re: if else statement error

Post by dk4210 »

What does it insert in the db?
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: if else statement error

Post by DigitalMind »

it's difficult to say because of your poor description.
maybe

Code: Select all

if ($seat)
Post Reply