🙂 hi!
I thank each one of you, who has taken the trouble to reply me, specially 'toplay' and 'Weedpacket', who continued helping me. I have learned a lot from you through this.
Well, the problem is solved, but i don't know how and i am sure this would sound weird. I went on working with the file, ignoring the error and suddenly i realised the error was not there any more, hope it won't come again. However, i thought i would post 1st 80 odd lines of code, if anyone's interested.
(Please note that the 2 closing } tags are there further down)
Code:
<?php
session_start();
if(!isset($_SESSION['user']))
{
//header("Location: http://www.forcestravel.com/index.php");
header("Location: index.php");
}
include("dbconfig.php");
$conn = mysql_connect($host, $user, $pWord, $dbName) or die("Connection failed...");
mysql_select_db($dbName, $conn) or die("Error...selecting database");
if ($_POST['Submit'] == 'Submit')
{
$error_msg ="";
$type_array= array();
$rate_array= array();
if ($_POST['select_types'] != ""){
foreach ($_POST['select_types'] as $key=> $value)
{
$type = $_POST['select_types'][$key];
$type_array[]=$type;
}
}
if ($_POST['rate'] != ""){
foreach ($_POST['rate'] as $key=> $value)
{
$rate = $_POST['rate'][$key];
$rate_array[]=$rate;
}
}
/* for ($i = 0; $i < count($type_array); $i++) {
$arr_type=$type_array[$i];
print "Type= ".$arr_type."<br>";
}
for ($i = 0; $i < count($rate_array); $i++) {
$arr_rate=$rate_array[$i];
print "Rate= ".$rate_array[$i]."<br>";
} */
// die();
$package_id = $_POST['package_name'];
$park_id = $_POST['park_name'];
$villa_id = $_POST["villa_name"];
$sdate = $_POST["datBegin"];
$edate = $_POST["datEnd"];
$cost = $_POST["cost"];
$holi_name = $_POST["holi_name"];
//Test print
print " St Date ".$sdate." End date ".$edate;
$sql = "SELECT * FROM holidays WHERE villa_id = '$villa_id' AND park_id = '$park_id' AND package_id = '$package_id' AND start_dt = '$sdate'";
$result = mysql_query($sql, $conn)or die("Invalid query...");
$row = mysql_fetch_row($result);
$num=mysql_numrows($result);
if ($num == 0)
{
$sql = "INSERT INTO holidays(start_dt, end_dt, villa_id, amount, holiday_name, park_id, package_id) values('$sdate', '$edate', '$villa_id','$cost', '$holi_name', '$park_id', '$package_id')";
//print $sql."<br>";
$result = mysql_query($sql, $conn)or die("Invalid query...");
$sql = "SELECT id FROM holidays WHERE villa_id = '$villa_id' AND park_id = '$park_id' AND package_id = '$package_id' AND start_dt = '$sdate'";
$result = mysql_query($sql, $conn)or die("Invalid query...");
$row = mysql_fetch_row($result);
$new_id = $row[0];
//print "id ".$new_id."<br>";
//--------
$sql = "SELECT * FROM discount_types ORDER BY type";
$result = mysql_query($sql, $conn)or die("Invalid query...");
$num_rec=mysql_numrows($result);
$new_rate = array();
for ($i = 0; $i< $num_rec; $i++)
{
if ($rate_array[$i] != "")
{
$new_rate[] = $rate_array[$i];
}
}
//----Test print----
print "count ".count($new_rate)."<br>";
for ($i = 0; $i < count($new_rate); $i++) {
print "New Rate= ".$new_rate[$i]."<br>";
}
//----------------
Have a great day!
Thanks & regards,
Pradee