Jump to content

mbrown

Members
  • Posts

    154
  • Joined

  • Last visited

Everything posted by mbrown

  1. I was corrected on the global. That has been removed. What is going on with this code is that it is a mailing function.
  2. 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 ?>
  3. 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
  4. 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"); ?>
  5. <?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?
  6. Thanks Jacques1! then I could do the conditional if $voteCount == $usercount ?
  7. 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.
  8. $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?
  9. Thank you jacques. That is the plan moving forward. I got alot of the functionality out there so we could start using the system. I have all ready created a bug in our bug tracking system to make sure that everything is handled like you explained with the PDO exceptions. I can not believe that I did not code those in since day 1. Again Thank you for your advise. If I do it this way then I could still use the bind parameter lines to set up those variables correct? When I was in school we used mysqli which I know is outdated now so this is my first attempt using PDO. Like Jacques1 stated, the code was not fine and that the syntax was incorrect. That is what I get for doing it while I was tired.
  10. The echo runs but the INSERT does not actually run. I have my my sql server running everything and the INSERT is not executing.
  11. I am not having fun with this code this evening. What am I missing? I know I am tired but still. Any help would be great! <?php include_once ('include/db-config.php'); #Debug: echo $_SERVER['HTTP_REFERER']; $motionid=$_POST['motionid']; $userid=$_POST['userid']; $text=$_POST['discussiontext']; #echo "Motion ID: " . $motionid . "<br />User ID: " . $userid . "<br />Text: " . $text . "<br />"; if ( strlen($text) == 0 ) { echo "You have not entered any text"; } else { $addDiscussion=$db_con->prepare( "INSERT INTO discussion (user_id,motion_id,discussion_text) VALUES(:userid, :motionid, :text"); $addDiscussion->bindParam(':userid',$userid); $addDiscussion->bindParam(':motionid',$motionid); $addDiscussion->bindParam(':text',$text); $addDiscussion->execute(); echo "Added Discussion Text"; } ?>
  12. Jaques1 thank you for the quick response. I see what you are saying. So what I want to do is provide the a list of all motions and they will choose one to vote on. What would be the best way to do this? Would it better to make each row a form and have a submit button for each row?
  13. So I have following code <p>Please choose a motion to vote on. Only one motion can be voted on at a time</p> <form id="vote" action="voting.php" method="post"> <table border="1" width="100%"> <tr> <th>Select</th> <th>Motion Text</th> <th>Date Added</th> </tr> <?php include_once ('include/db-config.php'); $motions=$db_con->prepare( "select * from motions where motion_disposition is NULL"); $motions->execute(); while ( $row = $motions->fetch(PDO::FETCH_ASSOC)) { ?> <tr> <td><input type="radio" name="<?php $row['motion_id']?>" id="<?php $row['motion_id']?>" value="<?php $row['motion_id']?>"</td> <td><?php echo $row['motion_name']; ?> </td> <td><?php echo $row['dateadded']; ?> </td> </tr> <?php }//end of while ?> </table> <input type="submit" value="Submit"> <input type="reset" value="Reset"> </form> When it goes to the page nothing is sent over when I print the $_POST array. I know I am missing something small but I can not put my finger on it Any help would be much appreciated.
  14. The user_id is a integer. ERROR REPORTING set to all DISPLAY ERRORS is enabled I am seeing it now. Not sure why it did not show up before. Thanks for the reminder about error reporting and display errors. That will help me out alot in the future in development.
  15. All right. I have it tested with the userid as shown above in the example. Nothing is printed out. I am currently in the session and nothing.
  16. Thanks. Can you give me an example of the debug message you are speaking of?
  17. <?php session_start(); if(empty($_SESSION['user_id'])){ header('location: index.php'); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Main Dashboard</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <link href="css/bootstrap.min.css" rel="stylesheet"> <link href="css/bootstrap-responsive.min.css" rel="stylesheet"> <link href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600" rel="stylesheet"> <link href="css/font-awesome.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet"> <link href="css/pages/dashboard.css" rel="stylesheet"> <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <?php $userid=$_SESSION['user_id']; echo $userid; ?> I have the above code. I am curious why I can not print out the userid on the page. I am using this as a roadmap as I want to include the username, first and last name in the session variables so I can use it throughout the current session to write out something like "Welcome First_Name Last_Name" Thanks for the help! Mike
  18. Thanks Jacques. Just create the necessary php and let cronjob run it?
  19. I am creating a PHP application that the HOA board will use to do some online voting between the board. That being said I would like to have an async job run every 24 hours at 6:00p.m. that would see what motions users have not voted on and e-mail them to let them know they need to vote on it. Any suggestions would be greatly appreicated
  20. Yes it is. mikeabrown.no-ip.org/fade.html
  21. I am attempting to get this demo to work in FF. The author has stated his code only works in Chrome. I have added the necessary -moz- calls for the CSS3 vendor specific calls. It still does not work in FF. The text is not supposed to be load all at once. It is supposed to load a little at a time. CSS @font-face { font-family: 'Qlassik'; src: url('http://bmcenterprises.wdfiles.com/local--files/fonts/Qlassik_TB-webfont.eot'); src: local('?'), url('http://bmcenterprises.wdfiles.com/local--files/fonts/Qlassik_TB-webfont.woff') format('woff'), url('http://bmcenterprises.wdfiles.com/local--files/fonts/Qlassik_TB-webfont.ttf') format('truetype'), url('http://bmcenterprises.wdfiles.com/local--files/fonts/Qlassik_TB-webfont.svg#webfont') format('svg'); font-weight: normal; font-style: normal; } html { height: 100%; width: 100%; } html { background-color: #fff; background-image: linear-gradient(top, #fff, #e4e4e4); } #content { display: block; position: absolute; top: 50%; width: 98%; padding: 0; margin-top: -200px; text-align: center; height: 400px; } .fade-in { font: normal 40px/2 'Qlassik'; color: #333; } .one {font-size: 50px;} .five {font-size: 30px;} @-moz-keyframes reset { 0% { opacity: 0; } 100% { opacity: 0; } } @keyframes reset { 0% { opacity: 0; } 100% { opacity: 0; } } @-moz-keyframes fade-in { 0% { opacity: 0; } 60% { opacity: 0; } 100% { opacity: 1; } } @keyframes fade-in { 0% { opacity: 0; } 60% { opacity: 0; } 100% { opacity: 1; } } .fade-in { -moz-animation-name: reset, fade-in; -moz-animation-duration: 3s; -moz-animation-timing-function: ease-in; -moz-animation-iteration-count: 1; animation-name: reset, fade-in; animation-duration: 3s; animation-timing-function: ease-in; animation-iteration-count: 1; } .fade-in.one { -moz-animation-delay: 0, 0; animation-delay: 0, 0; } .fade-in.two { -moz-animation-delay: 0, 1s; animation-delay: 0, 1s; } .fade-in.three { -moz-animation-delay: 0, 1.5s; animation-delay: 0, 1s; } .fade-in.four { -moz-animation-delay: 0, 2s; animation-delay: 0, 2s; } .fade-in.five { -moz-animation-delay: 0, 3s; animation-delay: 0, 3s;} a.again { background-color: #6bd3ee; background-image: linear-gradient(top, #6bd3ee, #2c9bd4); font-size: 20px; font-weight: normal; padding: 5px 18px; border-radius: 20px; border-top: 1px solid #baebfc; box-shadow: 1px 1px 0 #1c92b0, 0 2px 2px rgba(0,0,0,0.4); color: #fff; text-shadow: #257ca7 0 1px 1px; background-clip: padding-box; -webkit-background-clip: padding-box; text-decoration: none; font-family: 'Qlassik'; margin: 40px 10px 0; display: inline-block; -moz-animation-name: reset, fade-in; -moz-animation-duration: 6s; -moz-animation-timing-function: ease-in; -moz-animation-iteration-count: 1; -moz-animation-delay:0, 6s; animation-name: reset, fade-in; animation-duration: 6s; animation-timing-function: ease-in; animation-iteration-count: 1; animation-delay:0, 6s; } a.again:hover { background-color: #6ad9fa; background-image: linear-gradient(top, #6ad9fa), #39b0ed); color: #fff; text-decoration: none; } a.again:active { background-color: #22b4d9; background-image: none; } a.again.red { background-color: #b02b34; background-image: linear-gradient(top, #ee3c42), #b02b34); border-top: 1px solid #f1554a; box-shadow: 1px 1px 0 #bc2f38, 0 2px 2px rgba(0,0,0,0.4); text-shadow: #98262d 0 1px 1px; } a.again.red:hover { background-color: #ff434f; background-image: linear-gradient(top, #ff434f), #cb333a); } a.again.red:active { background-color: #ba313a; background-image: none; } a.again:before { content: '\2190 '; font-weight: bold; } a.again.red:before { content: ''; } HTML <div id="content"> <p> <span class="fade-in one">Tomorrow will be just another day.</span> </p> <p> <span class="fade-in two">That you will</span> <span class="fade-in three"> never</span> <span class="fade-in four"> forget.</span> </p> <p> <span class="fade-in five">See you at 10am.</span> </p> <p> <a href="/blog:animated-page-entry-with-css3" class="again">back to the BMC Blog</a> <a href="/local--code/blog:animated-page-entry-with-css3/5" class="again red">see it again</a> </p> </div>
  22. What will the div have in it? The div that is using jquery? or is this going to be more like a progression bar?
  23. How can you specify the salt but allow for all combinations? What I want to do is to utilize crypt to hash my passwords with a salt but as I am well aware each time it generates the hash, the salt is difference so the stored hash is different. If there a way to determine what the salt is? Either way when I know what the salt is, I will have to store it in my database table as the salt for each user will be different. Thanks M. Brown
  24. That is not the only thing and now I really can not tell what the issue was.
×
×
  • 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.