Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

mbrown's Achievements

Regular Member

Regular Member (3/5)



  1. I am trying to find examples of code for calendars that have the hours like amusement parks use https://www.dutchwonderland.com/hours-and-directions/hours-and-schedule that is one example
  2. I was curious to see if anyone has used LDAP with their PHP application. If you have what benefits does it provide over using a MySQL database? I am looking at expanding my knowledge of using PHP with various authentication services. I am not sure if this is in the right forum, if so please move it to the appropriate one.
  3. Thank you for your response Jacques. I will look into that. I have msmtp set up to be used by mail so that I can authenicate to gmail to send emails.
  4. It still does not work via the application. It is saying "msmtp: no recipients found"
  5. I changed to the following code and it seems to work some times. $headers .= "From: Tanyard Springs Votes <noreply@tanyardspringshoa.com>\r\n"; //mailing if (mail($boardEmail,$subject,$message,$headers)) print "Email successfully sent"; else print "An error occured"; }//end of function addmailing(52);
  6. So when I run the following command on the command line the mail is sent without issue echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" | msmtp --debug -a gmail mike.a.brown09@gmail.com --file=/etc/.msmtp_php Nothing is showing up in /var/log/msmtp.log or /var/log/mail.log file I now have the following in a file called test.php <?php if(mail("michaelbrown.tsbod@gmail.com","A Subject Here","Hi there,\nThis email was sent using PHP's mail function.")) print "Email successfully sent"; else print "An error occured"; ?> The /var/log/msmtp.log file shows the following: So both the echo statement and the going to test.php work fine and send the email. But when I have following code and run mail it does not work: <?php include_once('include/db-config.php'); function addmailing($votesmotionid) { global $db_con; $motionArray = array($votesmotionid); $userSearch=$db_con->prepare("SELECT * from users where enabled=1;"); $userSearch->execute(); foreach ($motionArray as $motionid) { while ($row=$userSearch->fetch(PDO::FETCH_ASSOC)) { $firstName = $row['first_name']; $lastName = $row['last_name'] ; $name="$firstName $lastName"; } $motion=$db_con->prepare ("SELECT * from motions where motion_id = :motionid"); $motion->bindParam(':motionid',$motionid); if (!$motion->execute()) var_dump($motion->errorinfo()); $body="<html> <head> <title>New Motion Addded</title> </head> <body>"; $body .= "Dear $name <br /><br />"; $body .= "A new electronic vote has been created, please review it as soon as possible. The information is below."; while ($row=$motion->fetch(PDO::FETCH_ASSOC)) { $motionid=$row['motion_id']; $motionname=$row['motion_name']; $dateadded=$row['dateadded']; $motiondesc=$row['motion_description']; $body .= "<br ><br />Motion ID: " . $motionid; $body .= "<br />Motion Name: " . $motionname; $body .= "<br />Date Added: " . $dateadded; $body .= "<br />Motion Text: " . $motiondesc; }//End of while $body .= "</body> </html>"; }//end of foreach $boardEmail = ""; $emailSearch=$db_con->prepare("SELECT * FROM users where enabled=1"); $emailSearch->execute(); while ($row=$emailSearch->fetch(PDO::FETCH_ASSOC)) { $boardEmail .= $row['email'] .","; } $subject = "New Motion " . $motionid; echo "Board Email: " . $boardEmail; $message = $body; $headers = ""; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $headers .= "To: $boardEmail\r\n"; $headers .= "From: Tanyard Springs Votes <noreply@tanyardspringshoa.com>\r\n"; //mailing mail($boardEmail,$subject,$message,$headers); }//end of function addmailing(52); Any help determining what is the issue would be greatly appreciated. The code base in the last example is rough code which will be fixed once I have this mail issue resolved.
  7. I was corrected on the global. That has been removed. What is going on with this code is that it is a mailing function.
  8. I am getting an error in my following code. The error is This would make it on the this line: global $body .= "<h1>" . $motionname . "</h1> <?php function mailing($motionid) { $motionArray = array($motionid); foreach ($motionArray as $motion) { //Database Connection include_once ('include/db-config.php'); $motion=$db_con->prepare ("SELECT * from motions where motion_id = :motionid"); $motion->bindParam(':motionid',$motionid); $motion->execute(); $body="<html> <head> <title>Status of Motion</title> </head> <body>"; while ($row=$motion->fetch(PDO::FETCH_ASSOC)) { $motionid=$row['motion_id']; $motionname=$row['motion_name']; $dateadded=$row['dateadded']; $motiondesc=$row['motion_description']; $disposition=$row['motion_disposition']; global $body .= "<h1>" . $motionname . "</h1> <h2>Date Added:</h2>" . $dateadded . "<br /> <h2>Motion Text</h2>" . $motiondesc; "<h2>Disposition:</h2>" . $disposition; }//End of while global $body .= "<br /><br /> <h2>Current Votes</h2> <table border=\"1\" width=\"100%\"> <tr> <th>User</th> <th>Date</th> <th>Vote</th> </tr>"; $votes=$db_con->prepare( "SELECT u.first_name, u.last_name, v.time, v.vote from votes v inner join motions m on m.motion_id=v.motions_id INNER join users u on u.users_id=v.users_id where m.motion_id=:motionid ORDER BY v.time ASC;"); $votes->bindParam(':motionid',$motionid); $votes->execute(); while ($row=$votes->fetch(PDO::FETCH_ASSOC)) { $firstname=$row['first_name']; $lastname=$row['last_name']; $votetime=$row['time']; $votecast=$row['vote']; global $body .= "<tr> <td>" . $firstname . " " . $lastname . "</td> <td>" . $votetime . "</td> <td>" . $votecast . "</td> </tr>"; }// while ($row=$votes->fetch(PDO::FETCH_ASSOC)) global $body .= "</table>"; global $body .= "<br /><br /> <h2>Discussions</h2> <table border=\"1\" width=\"1\"> <tr> <th>User</th> <th>Date</th> <th>Comment</th> </tr>"; $motiondiscussions=$db_con->prepare( "SELECT u.first_name,u.last_name,d.dateadded,d.discussion_text from users u inner join discussion d on d.user_id=u.users_id where d.motion_id=:motionid"); $motiondiscussions->bindParam(':motionid',$motionid); $motiondiscussions->execute(); while ($row=$motiondiscussions->fetch(PDO::FETCH_ASSOC)) { $firstname=$row['first_name']; $lastname=$row['last_name']; $discussiontime=$row['dateadded']; $discussiontext=$row['discussion_text']; global $body .= "<tr> <td>" . $firstname . " " . $lastname . "</td> <td>" . $discussiontime . "</td> <td>" . $discussiontext . "</td> </tr>"; }//end of while global $body .= "</table>"; global $body .= "</body> </html>"; }//end of foreach $email="michaelbrown.tsbod@gmail.com"; $to="michaelbrown.tsbod@gmail.com"; $subject = "Summary for Motion " . $motionid; $message = $body; $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: text/html; charset=iso-8859-1'; $headers[] = 'To: Michael Brown <michaelbrown.tsbod@gmail.com>'; $headers[]= 'From: Tanyard Springs Votes <noreply@tanyardspringshoa.com>'; //mailing mail($to,$subject,$message, implode("\r\n", $headers)); }//end of function ?>
  9. Thanks pyscho. Again I have only given part of the code. I did not think about it. I can easily update the SQL to do things like that. Thanks again
  10. I see I could do it something like this too <?php /* Delete all rows from the FRUIT table */ $del = $dbh->prepare('DELETE FROM fruit'); $del->execute(); /* Return number of rows that were deleted */ print("Return number of rows that were deleted:\n"); $count = $del->rowCount(); print("Deleted $count rows.\n"); ?>
  11. <?php $userCount = $db_con->query('SELECT COUNT(*) FROM users WHERE enabled=1')->fetchColumn(); $userCount -> execute(); $voteCountStmt = $db_con->prepare('SELECT COUNT(*) FROM votes WHERE motions_id = :motionid'); $voteCountStmt->execute(['motionid' => $motionid]); $voteCount = $voteCountStmt->fetchColumn(); if ($voteCount == $ $userCount) { //Update Final Disposition to PASSED } else { exit; } So something like the above?
  12. Thanks Jacques1! then I could do the conditional if $voteCount == $usercount ?
  13. I have printed out the count from both. The rows got inserted when a person votes on a motion. Based on Jacques1 reply it could be because I am using an incorrect function for what I want. Thank you for this information. That being said, I will do some research to identify what I need to do to count rows not columns. The second query may not always be one. It could be anything between 0 and 5 depending on how many people have voted on it. I need this to determine when we can set the motion_disposition column to PASSED in the motions table.
  14. $enabledCount=$db_con->prepare( "SELECT * FROM users where enabled=1;"); $enabledCount->execute(); $row=$enabledCount->fetchAll(PDO::FETCH_ASSOC); $usercount=count($row); $votecount=$db_con->prepare( "SELECT * FROM votes where motions_id=:motionid"); $votecount->bindParam(':motionid',$motionid); $votecount->execute(); $voterow=$votecount->fetch(PDO::FETCH_ASSOC); $votecount=count($voterow); My code is above. The first one should return 5 but the second one should only return one. What am I missing?
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.