0
<?php

     //redirect the user to login if session is invalid
     include("validate_session.php");
	$alert =0;

         $userid=$_SESSION["userid"];

         //Connecting to database
         include("db_connect.php");

         foreach ($_POST as $key => $value)
             if  (substr($key,0,8) =="txt_chk_")
             {
			$alert =1;
			 
			  $itemid=substr($key,8,3);
			  $purtime=substr($key,11,8);
			  $purdate=substr($key,19,10);
			  $itemdate=substr($key,8);
						  
              foreach ($_POST as $key1 => $value1)
               if ($key<>$key1)
               {
                 $tempstr= substr($key1,0,strlen($key1)-strlen($itemdate));
                 if (substr($key1,strlen($tempstr))==$itemdate)
                 {
                     if ($tempstr=="txt_qty_")
                          $qty = $value1;

                     if ($tempstr=="txt_price_")
                          $price = $value1;


                     if ($tempstr=="txt_date_")
                           $date = $value1;
						   
					
                 }//end if

               }//end if
	/////////////////////////////////////////////////////////////////////////////////		   
	$Rs=mysql_query("Select * from sales where userid ='$userid' and itemid ='$itemid' and sdate=NOW()");	
	
	if(mysql_num_rows($Rs) > 0)
		{ $rows = mysql_fetch_array($Rs); 
		$newqty = $rows["qty"] + $qty;
		$sql_update ="UPDATE sales set qty=$newqty where userid ='$userid' and itemid ='$itemid' and sdate =NOW()";
				if (!mysql_query($sql_update,$con))
                {
                 die('Error: ' . mysql_error());
                }
		}	
		
		else  
            {    //Buiding the insert statement for sales
				               $sql_insert= "INSERT INTO sales (Userid, itemid,sdate,price,qty) VALUES ('$userid','$itemid',NOW(), $price , $qty)";

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

}///////////////////////////////////////////////////////////////////////////////////
                //Building the update statement for basket
                $sql_update="Update basket set status ='s' WHERE userid='$userid' AND itemid='$itemid' AND date='$date $purtime' and ptime='$purtime' and status='p'";
				
				if (!mysql_query($sql_update,$con))
				
                {
                 die('Error: ' . mysql_error());
                }
				
				$sql_delete="DELETE FROM basket WHERE status='p'";
				
				if (!mysql_query($sql_delete,$con))
			{
				die('Error: ' . mysql_error());
			}

             }//endif
			 
						
             mysql_close($con);
			 
		?>
 <html>
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>

<body>
<?php if ($alert =='0')
{
/* echo $itemid;
 echo "<br>";
echo $purtime;
 echo "<br>";
 echo $purdate;
  echo "<br>";
echo $itemdate;
 echo "<br>";*/
?>
<center>
<h2>Credit Card Details</h2>
<img src="images/creditcard.jpg" width="258" height="126"/>
</center>
<script type="text/javascript">
<!--


function validateNumericCreditCard()
{
	var str="0123456789";
	var sid=document.frm_creditcard.txt_CardNumber.value;
	
	if ((sid.length)!=16)
	{
		alert("Credit card number must contain exactly 16 numbers");
		return false;
	}
	
	for(i=0; i<sid.length; i++)
	{
		if(str.indexOf(sid.charAt(i))==-1)
		{
			alert("Please enter numeric character for Credit Card");
			return false;
		}//end if
	}//end for
	return true;
}

-->
</script>

<form name=frm_creditcard action="congrats.html" onSubmit="return validateNumericCreditCard()">

<table cellpadding="7" align="center">
<tr><td>Card Number: </td>
	<td><input name="txt_CardNumber" size="16" maxlength="16" ></td></tr>
<tr><td>Card Type:</td>
<td><select name="CardType">
	<option value="MasterCard">MasterCard
	<option value="VisaCard">Visa
	<option value="AmExCard">American Express
	<option value="DinersClubCard">Diners Club
	<option value="DiscoverCard">Discover
	<option value="enRouteCard">enRoute
	<option value="JCBCard">JCB
</select></td></tr>
<tr><td colspan="2"><input name="Submit" type="submit" value="Submit" /></td></tr>
</table>
</form>
<? 
}

else
{
echo "<h2 align='center'><b>Error</b></h2>"; 
echo "Please make sure that you have selected at least one item from your basket to buy!";
?>
<br>
<br>

<input type="button" value="OK" name="btn_ok" onClick="window.location='login_pro.php'">
<?
}?>

</body>
</html>

I've got an error on this page and i cant spot what is the error.I think it has something to do with the database. Can someone tell me the mistake in this code please?The error is "Parse error: syntax error, unexpected $end in C:\xampp\htdocs\flower\purchase.php on line 173"

The database name and details are attached to this document. Thank for the help in advance.

Attachments
-- phpMyAdmin SQL Dump
-- version 2.6.1
-- http://www.phpmyadmin.net
-- 
-- Host: localhost
-- Generation Time: Apr 29, 2009 at 09:25 AM
-- Server version: 4.1.9
-- PHP Version: 4.3.10
-- 
-- Database: `plants`
-- 

-- --------------------------------------------------------

-- 
-- Table structure for table `basket`
-- 

CREATE TABLE `basket` (
  `userid` char(10) NOT NULL default '',
  `itemid` char(3) NOT NULL default '',
  `date` datetime NOT NULL default '0000-00-00 00:00:00',
  `price` float NOT NULL default '0',
  `qty` int(11) NOT NULL default '0',
  `status` char(1) NOT NULL default '',
  `ptime` time NOT NULL default '00:00:00'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- 
-- Dumping data for table `basket`
-- 


-- --------------------------------------------------------

-- 
-- Table structure for table `item`
-- 

CREATE TABLE `item` (
  `itemid` char(3) NOT NULL default '',
  `name` text NOT NULL,
  `picture` varchar(50) NOT NULL default '',
  `listprice` float NOT NULL default '0',
  `stock` varchar(20) NOT NULL default '',
  `adddate` date NOT NULL default '0000-00-00',
  PRIMARY KEY  (`itemid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- 
-- Dumping data for table `item`
-- 

INSERT INTO `item` VALUES ('1', '1_Doz_Orange_Roses', 'src="images/OrangeRoses.jpg"', 175, '14', '2009-01-01');
INSERT INTO `item` VALUES ('2', '1_Doz_Red_Roses', 'src="images/RedRoses.jpg"', 200, '6', '2009-01-01');
INSERT INTO `item` VALUES ('3', '1_Doz_Pink_Roses_Ref2039', 'src="images/PinkRoses2039.jpg"', 150, '10', '2009-01-01');
INSERT INTO `item` VALUES ('4', '1_Doz._Rainbow_Roses_Bouquet_Ref2041', 'src="images/RainbowRoses2041.jpg"', 180, '5', '2009-01-01');
INSERT INTO `item` VALUES ('5', '1_Doz._White_Roses_Ref2038', 'src="images/WhiteRoses.jpg"', 160, '4', '2009-01-01');
INSERT INTO `item` VALUES ('6', '2_Doz._Assorted_Color_Roses', 'src="images/AssortedRoses.jpg"', 400, '2', '2009-01-01');
INSERT INTO `item` VALUES ('7', '20_Fresh_Cut_Purple_Tulips', 'src="images/PurpleTulips.jpg"', 225, '2', '2009-01-01');
INSERT INTO `item` VALUES ('8', 'Bright&Light_Bouquet', 'src="images/Bright&LightBouquet.jpg"', 350, '5', '2009-01-01');
INSERT INTO `item` VALUES ('9', 'Carnation_Mix_Bouquet', 'src="images/CarnationMix.jpg"', 300, '4', '2009-01-01');
INSERT INTO `item` VALUES ('10', 'Elegant_Pink_Roses', 'src="images/ElegantPinkRoses.jpg"', 500, '2', '2009-01-01');
INSERT INTO `item` VALUES ('11', 'Spring_Bouquet', 'src="images/SpringBouquet.jpg"', 250, '8', '2009-01-01');
INSERT INTO `item` VALUES ('12', 'Seasonal_Color''s_Bouquet', 'src="images/SeasonalColorsBouquet.jpg"', 300, '4', '2009-01-01');
INSERT INTO `item` VALUES ('13', 'Early_Sunshine_Bouquet', 'src="images/earlysunshine.jpg"', 400, '5', '2009-01-01');
INSERT INTO `item` VALUES ('14', 'Classic_White_Flower_Bouquet', 'src="images/ClassicwhiteBouquet.jpg"', 400, '3', '2009-01-01');
INSERT INTO `item` VALUES ('15', 'Blazing_Sunset_Bouquet', 'src="images/blazingsunset.jpg"', 350, '9', '2009-01-01');
INSERT INTO `item` VALUES ('16', 'Nature''s_Best_Bouquet', 'src="images/NaturesBouquet.jpg"', 275, '12', '2009-01-01');
INSERT INTO `item` VALUES ('17', 'Mix_Flower_Bouquet', 'src="images/MixFlowerBouquet.jpg"', 325, '10', '2009-01-01');
INSERT INTO `item` VALUES ('18', 'Lovely_Lavender_Fresh_Flowers', 'src="images/LovelyLavender.jpg"', 475, '3', '2009-01-01');
INSERT INTO `item` VALUES ('19', 'Hybrid_Stargazer_Lily', 'src="images/HybridStargazerLily.jpg"', 375, '5', '2009-01-01');
INSERT INTO `item` VALUES ('20', 'Glorious_Sunflower_Bouquet ', 'src="images/sunflower.jpg"', 175, '10', '2009-01-01');
INSERT INTO `item` VALUES ('21', 'Flowers_Moonlight_Sonata_Lilies_with_Vase', 'src="images/SonataLilies.jpg"', 150, '12', '2009-01-01');
INSERT INTO `item` VALUES ('22', 'Gerbera_Bouquet', 'src="images/gerbera bouquet.jpg"', 225, '10', '2009-01-01');
INSERT INTO `item` VALUES ('23', 'Lady_in_Red_Bouquet', 'src="images/LadyInRed.jpg"', 150, '11', '2009-01-01');
INSERT INTO `item` VALUES ('24', 'Mixed_Spring_Bouquet', 'src="images/MixedSpringBouquet.jpg"', 500, '3', '2009-01-01');
INSERT INTO `item` VALUES ('25', 'Glorious_Pink_Carnation_Bouquet', 'src="images/PinkCarnationBouquet.jpg"', 550, '5', '2009-01-01');
INSERT INTO `item` VALUES ('26', '1_Dozen_Yellow_Roses_Wrapped', 'src="images/12YellowRoses.jpg"', 300, '4', '2009-01-14');

-- --------------------------------------------------------

-- 
-- Table structure for table `meaning`
-- 

CREATE TABLE `meaning` (
  `id` char(3) NOT NULL default '',
  `name` varchar(15) NOT NULL default '',
  `picture` varchar(50) NOT NULL default '',
  `meaning` varchar(50) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- 
-- Dumping data for table `meaning`
-- 

INSERT INTO `meaning` VALUES ('1', 'Acacia', 'src="images/meaning/Acacia2.jpg"', 'Secret_Love,Beauty_in_Retirement,Chaste_Love');
INSERT INTO `meaning` VALUES ('2', 'Calla Lily', 'src="images/meaning/callalily.jpg"', 'Beauty');
INSERT INTO `meaning` VALUES ('3', 'Camellia', 'src="images/meaning/camellia.jpg"', 'Admiration,Perfection,Good_Luck_Gift_to_a_Man');
INSERT INTO `meaning` VALUES ('4', 'Carnation', 'src="images/meaning/carnation.jpg"', 'Fascination,My_Heart_Aches_for_You,Admiration');
INSERT INTO `meaning` VALUES ('5', 'Daisy', 'src="images/meaning/daisy.jpg"', 'Innocence,Loyal_Love');
INSERT INTO `meaning` VALUES ('6', 'Jasmine', 'src="images/meaning/jasmine.jpg"', 'Amiability');
INSERT INTO `meaning` VALUES ('7', 'Lilac', 'src="images/meaning/lilac.jpg"', 'Do_You_Still_Love_Me?');
INSERT INTO `meaning` VALUES ('8', 'Lily', 'src="images/meaning/lily.jpg"', 'Coquetry,Pride,Purity');
INSERT INTO `meaning` VALUES ('9', 'Orchid', 'src="images/meaning/orchid.jpg"', 'Love,Beauty,Refinement');
INSERT INTO `meaning` VALUES ('10', 'Rose', 'src="images/meaning/rose.jpg"', 'I_Love_You');
INSERT INTO `meaning` VALUES ('11', 'Rosebud', 'src="images/meaning/rosebud.jpg"', 'Beauty&Youth,A_Heart_Innocent_of_Love');
INSERT INTO `meaning` VALUES ('12', 'Tulip', 'src="images/meaning/tulip.jpg"', 'Perfect_Lover,Fame,Declaration_of_Love');
INSERT INTO `meaning` VALUES ('13', 'Zinnia', 'src="images/meaning/zinnia.jpg"', 'Lasting_Affection,Goodness,Daily_Remembrance');

-- --------------------------------------------------------

-- 
-- Table structure for table `sales`
-- 

CREATE TABLE `sales` (
  `Userid` char(10) NOT NULL default '',
  `itemid` char(3) NOT NULL default '',
  `sdate` datetime NOT NULL default '0000-00-00 00:00:00',
  `price` float NOT NULL default '0',
  `qty` int(2) NOT NULL default '0',
  PRIMARY KEY  (`Userid`,`itemid`,`sdate`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- 
-- Dumping data for table `sales`
-- 

INSERT INTO `sales` VALUES ('1', '112', '2009-01-13 22:05:49', 175, 1);
INSERT INTO `sales` VALUES ('rami', '420', '2009-01-14 20:45:08', 180, 1);
INSERT INTO `sales` VALUES ('rami', '420', '2009-01-14 20:49:22', 180, 1);
INSERT INTO `sales` VALUES ('rami', '420', '2009-01-14 20:49:32', 180, 1);
INSERT INTO `sales` VALUES ('rami', '220', '2009-01-14 20:49:32', 200, 1);
INSERT INTO `sales` VALUES ('rami', '420', '2009-01-14 21:01:33', 180, 1);
INSERT INTO `sales` VALUES ('rami', '420', '2009-01-14 21:02:44', 180, 1);
INSERT INTO `sales` VALUES ('rami', '152', '2009-01-15 21:11:19', 350, 1);
INSERT INTO `sales` VALUES ('rami', '152', '2009-01-15 21:13:05', 350, 1);
INSERT INTO `sales` VALUES ('rami', '152', '2009-01-15 21:14:31', 350, 2);
INSERT INTO `sales` VALUES ('rami', '152', '2009-01-15 21:14:53', 350, 2);
INSERT INTO `sales` VALUES ('rami', '152', '2009-01-15 21:15:09', 350, 2);
INSERT INTO `sales` VALUES ('rami', '420', '2009-01-15 21:17:18', 180, 1);
INSERT INTO `sales` VALUES ('rami', '420', '2009-01-15 21:23:04', 180, 1);
INSERT INTO `sales` VALUES ('rami', '420', '2009-01-15 21:34:49', 180, 1);
INSERT INTO `sales` VALUES ('rami', '118', '2009-01-27 18:17:38', 175, 2);
INSERT INTO `sales` VALUES ('rami', '118', '2009-01-27 18:17:57', 175, 2);
INSERT INTO `sales` VALUES ('rami', '118', '2009-01-27 18:18:24', 175, 2);
INSERT INTO `sales` VALUES ('rami', '118', '2009-01-27 18:19:48', 175, 2);
INSERT INTO `sales` VALUES ('rami', '118', '2009-01-27 18:19:55', 175, 2);
INSERT INTO `sales` VALUES ('rami', '118', '2009-01-27 18:20:18', 175, 2);
INSERT INTO `sales` VALUES ('rami', '118', '2009-01-27 18:52:12', 175, 2);
INSERT INTO `sales` VALUES ('rami', '807', '2009-01-31 07:54:17', 350, 2);
INSERT INTO `sales` VALUES ('rami', '307', '2009-01-31 07:54:17', 150, 1);
INSERT INTO `sales` VALUES ('rami', '307', '2009-01-31 12:05:43', 150, 1);
INSERT INTO `sales` VALUES ('rami', '307', '2009-02-03 19:13:35', 150, 1);
INSERT INTO `sales` VALUES ('rami', '307', '2009-02-03 19:14:20', 150, 1);
INSERT INTO `sales` VALUES ('rami', '307', '2009-02-03 19:17:24', 150, 1);
INSERT INTO `sales` VALUES ('rami', '307', '2009-02-03 19:19:56', 150, 1);
INSERT INTO `sales` VALUES ('rami', '119', '2009-02-03 19:44:54', 175, 1);
INSERT INTO `sales` VALUES ('rami', '119', '2009-02-03 19:46:42', 175, 1);
INSERT INTO `sales` VALUES ('rami', '307', '2009-02-03 19:49:17', 150, 1);
INSERT INTO `sales` VALUES ('test', '231', '2009-02-03 19:58:31', 150, 1);
INSERT INTO `sales` VALUES ('test', '419', '2009-02-03 19:58:31', 180, 1);
INSERT INTO `sales` VALUES ('test', '319', '2009-02-03 19:58:31', 150, 1);
INSERT INTO `sales` VALUES ('test', '319', '2009-02-03 20:04:00', 150, 1);
INSERT INTO `sales` VALUES ('test', '319', '2009-02-03 20:04:44', 150, 1);
INSERT INTO `sales` VALUES ('test', '120', '2009-02-03 20:05:23', 175, 1);
INSERT INTO `sales` VALUES ('rami', '151', '2009-04-26 18:07:22', 350, 1);
INSERT INTO `sales` VALUES ('rami', '141', '2009-04-26 18:07:22', 400, 1);

-- --------------------------------------------------------

-- 
-- Table structure for table `users`
-- 

CREATE TABLE `users` (
  `id` int(3) NOT NULL auto_increment,
  `Userid` varchar(10) NOT NULL default '',
  `UserName` varchar(20) NOT NULL default '',
  `UserPassword` varchar(10) NOT NULL default '',
  `UserType` varchar(5) NOT NULL default '',
  `Email` varch
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by kek1205
0

I removed codes from line 93 to 103 and from 155 to 162. The mistake is no longer present but the form does not do its work as intended. Let me know asap plz.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.