do I have to open another connection in an include file where i the main file a connection has already been made?
Somehow my code doesn't seem to access the database
here is my code:-
<?
include("config.php");
// open a connection to the database
$connection = mysql_connect($server, $user, $pass);
// formulate the SQL query - same as above
$query = "SELECT * from calendar WHERE date='$this_date' order by time";
// run the query on the database
$result = mysql_db_query($db,$query,$connection);
$message="This email is to remind you that your appointment with Daniel is scheduled at $this_time on $this_date. Please do no reply this email. This is an automatically generated email";
$from_address="daniel@mail.net";
if(mysql_num_rows($result)>0)
{ while ($row=mysql_fetch_array($result))
{
$this_date=$row["date"];
$this_time=$row["time"];
$comment=$row["comment"];
$id=$row["id"];
$email=$row["email"];
$sent=$row["sent"];
if($sent=='NO')
if($email)
{mail($email,$message, $from_address);}
$query2 = "UPDATE calendar SET sent='YES' WHERE id='$id'";
// run the query on the database
$result2 = mysql_db_query($db,$query2 ,$connection);
echo "Database updated";
}
}
// close connection
mysql_close($connection);
?>
what I am trying to do is, on the date that is contained within the database, the file will send an email to the email address in the particular line and set the "sent" column to "YES". This code is actually based on the code by Melonfire, a code where an online calendar is produced to keep appointments for the user. i downloaded this code from www.devshed.com. Please help as I am new to PHP aand MySQL, just started a week ago.