Code: Select all
<?php
//mysql connect
$con = mysql_connect("localhost","robbroa1_dbuser","GKk&HRVb|fx(");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
//open db
mysql_select_db("robbroa1_fox", $con);
//pull input variables
$month = $_POST["month"];
$year = $_POST["year"];
$pw = $_POST["pw"];
//capture days in the month
$date = mktime(0,0,0, $month, 1, $year);
$days_in_month = date('t', $date);
//global counting vars
$day_count = 1;
$times_count = 1;
while( $day_count <= $days_in_month && $pw == 'success')
{
// time for current counter day
$fill_day = mktime(0,0,0, $month, $day_count, $year);
$fill_day_of_week = date('w', $fill_day);
// 0 is Sunday
// 1 is Monday
// 2 is Tuesday
// 3 is Wednesday
// 4 is Thursday
// 5 is Friday
// 6 is Saturday
if( $fill_day_of_week == 0 )
{
$times[0]="12:00";
$times[1]="02:00";
$times[2]="04:00";
$times[3]="06:00";
$number_of_times = "4";
}
else if( $fill_day_of_week == 1 )
{
$times[0]="12:00";
$times[1]="02:00";
$times[2]="04:00";
$times[3]="06:00";
$number_of_times = "4";
}
else if( $fill_day_of_week == 2 )
{
$times[0]="12:00";
$times[1]="02:00";
$times[2]="04:00";
$times[3]="06:00";
$number_of_times = "4";
}
else if( $fill_day_of_week == 3 )
{
$times[0]="12:00";
$number_of_times = "1";
}
else if( $fill_day_of_week == 4 )
{
$times[0]="06:00";
$number_of_times = "1";
}
else if( $fill_day_of_week == 5 )
{
$times[0]="06:00";
$number_of_times = "1";
}
else if( $fill_day_of_week == 6 )
{
$times[0]="12:00";
$times[1]="02:00";
$times[2]="04:00";
$times[3]="06:00";
$number_of_times = "4";
}
while( $times_count <= $number_of_times )
{
$value = $times[$times_count];
$retval = mysql_query("
INSERT INTO appt (month, day, year, time, ampm)
VALUES ('$month', '$day', $year', '$value', 'PM')
");
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
$times_count++;
}
//increment
$day_count++;
$times_count = 1;
}
?>
Any help would be greatly appreciated.Could not update data: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '', '02:00', 'PM')' at line 2
Cheers