Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. Hmm, I am also going to have to take into account about the different years, because it will mess up everytimes years change if that's not taken into account. Anyone have any advice on this.
  2. I need to come up with something that will take the current month, for example this month is april. It would create a drop down list like Feb 1 - feb 30 march 1 - march 30 April 1 - April 30 Basically the last 3 months, including this one. Then I am going to need to save the month as the value, so I can pass it to the script so I know what date ranges I am looking for. I can't think of a logical way to do this, and still account for the fact that some months have 29 days, some have 30, and some have 31.
  3. <?php // checks if form is coming from the right place, and is sset if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; $select = "SELECT * FROM transactions WHERE id = '$id' AND userid = '" . $_SESSION['member'] . "';"; $query = mysql_query($select); if ($row = mysql_fetch_array($query)) { ?> <table border="0" cellspacing="0" cellpadding="4" class="memAcctOverviewTbl"> <tr> <td><a href="javascript:void(0);" onmouseover="return overlib('Field help text goes here');" onmouseout="return nd();"><img border="0" src="<?php echo $wwwpath; ?>common/images/button_question.gif" width="17" height="17" align="left" /></a> <strong> Transaction ID:</strong></td> <td><?php echo $row['transactionid']; ?></td> <td></td> </tr> <tr> <td><a href="javascript:void(0);" onmouseover="return overlib('Field help text goes here');" onmouseout="return nd();"><img border="0" src="<?php echo $wwwpath; ?>common/images/button_question.gif" width="17" height="17" align="left" /></a> <strong> Transaction Type:</strong></td> <?php // this get's the type since it varies. // based on the type we are going to need to show different things if ($row['type'] == "Deposit") { $type = "Deposit"; }elseif ($row['type'] == "Bill") { // this includes the billers name if it's a bill $selectbiller = "SELECT * FROM biller WHERE id = '" . $row['biller_or_account'] . "';"; $querybiller = mysql_query($selectbiller); if ($rowbiller = mysql_fetch_array($querybiller)) { $type = $rowbiller['billersname']; } }elseif ($row['type'] == "Payment") { $type = "Payment"; } ?> <td><?php echo $type; ?></td> <td></td> </tr> <tr> <td><a href="javascript:void(0);" onmouseover="return overlib('Field help text goes here');" onmouseout="return nd();"><img border="0" src="<?php echo $wwwpath; ?>common/images/button_question.gif" width="17" height="17" align="left" /></a> <strong> Transaction Amount:</strong></td> <td><?php echo number_format($row['amount'], 2); ?></td> <td></td> </tr> <tr> <td><a href="javascript:void(0);" onmouseover="return overlib('Field help text goes here');" onmouseout="return nd();"><img border="0" src="<?php echo $wwwpath; ?>common/images/button_question.gif" width="17" height="17" align="left" /></a> <strong> Transaction Date:</strong></td> <td><?php echo date("m/d/Y", $row['submitted']); ?></td> <td></td> </tr> <tr> <td><a href="javascript:void(0);" onmouseover="return overlib('Field help text goes here');" onmouseout="return nd();"><img border="0" src="<?php echo $wwwpath; ?>common/images/button_question.gif" width="17" height="17" align="left" /></a> <strong> Transaction Status:</strong></td> <td><?php echo $row['status']; ?></td> <td></td> </tr> </table> <?php // here we need to check if the status is pending so we can output when it's changing to posted. if ($row['status'] == "Pending") { // in order to get the date, we have to do calculations at this point based on the Type of // transaction that we are currently dealing with // CALCULATIONS if ($row['type'] == "Bill" || $row['type'] == "Payment") { $newtime = strtotime("+2 days", $row['submitted']); }elseif ($row['type'] == "Deposit") { $newtime = strtotime("+3 days", $row['submitted']); } // END CALCULATIONS ?> <p>Due to its <strong>Pending</strong> status, you may cancel this transaction before <?php echo date("F j, Y, g:i a", $newtime); ?></p> <?php } // end check for pending } } ?> Here is what I was currently working on. It's working code, and it all functions. This is an example, because I have the date stuff but it's just one part of a whole view of information.
  4. 90% of the time I end up having to work with a date within other fields. I have to pull out a bunch of fields, and 2-3 of them are dates that I have to do specific calculations with. They sometimes need to be outputted in multiple formats, adn sometimes have different calculations done. If i used the mysql standard date format would I still have this flexibility. I was concerned awhile back about date's, because I just saved it in the database under varchar using whatever format I needed to accept, Ihad many problems so someone on here introduced me to timestamps I have been using them ever since much smoother. I have never used mysql's built in date format, however so I am unsure what it does/is. I know it's a specific way it formats the date's, but are they easier (based on the usage I explained above) easier to work with than unix timestamps.
  5. Sorting/date ranges are easy. The calculations are now $now = strtotime("Now"); $tomorrow = strtotime("+1 day", $now); $yesterday = strtotime("-1 day", $now); $nextMonth = strtotime("+1 month", $now); That made a lot of sense, however I am just needing a list of the different arguments that first one can take. Here -1 day +1 day I am guessing you can put in more than 1 day, probably the same for month. I like the way that looks. Easy to use, accurate, and simple. I always run off unix timestamps, and I am just looking for a quick way to do calculations, sorting them's never been much of a problem, but doing lot's of calculations are. Is there a comprehensive list somewhere of the other arguments that first one can take.
  6. Yes, I have a unix timestamp. Do you have a list of those arguments (now, + 1 month) and all those other stuff you showed for strtotime I didn't see those listed anywhere on php.net. Do you have a list or a reference page or something where you learned them at?
  7. What is the most RELIABLE way to do date calculations. The system I am working on is going to require a LOT of date calculations. Like getting a month from the given date, or 3 days from it, or 4 days from it, or comparing months. I need to find a good way to do date calculations, any advice.
  8. That I did not think of, in that scenariou they could pass an array, I have to look into that more, thanks.
  9. Your better off setting up a cron job. That could not be 100% secure, meaning there could be other issues. Even then, that time would have to somehow be ran. You can do the calculations easy enough, but a cron job (which would simply be telling the server to run that specific php script at whatever time period) would be a lot more reliable, and a lot faster. That's what I would suggest. What webhost do you use, what plan do you have, check and see if they support cron jobs, if not there are some other alternatives you can look into.
  10. I have always used the following $_POST for post variables $_GET for get variables $_SESSION for session variables $_COOKIES for cookie variables and $_FILES for file variables. I am not 100% but lately I have noticed I sometimes have 1 defining variable that could be either get/post. I noticed using $_REQUEST on ones that could be either, is that basically the same thing. Is it insecure. For instance id's. sometimes they are post, sometimes get. I normally use to do if (isset($_POST['id'])) { $id = mysql_real_escape_string($_POST['id']); }elseif (isset($_GET['id'])) { $id = mysql_real_escape_string($_GET['id']); }else { $id = "no"; } Basically but the other way things are like if (isset($_REQUEST['id'])) { $id = mysql_real_escape_string($_REQUEST['id']); }else { $id = "no"; } Basically just a quick example, I notice that if I have this setup like this, it's a little faster. Is there something wrong with the request variable. Mostly for "switch" statements (like a front controller or something), there would be different variables getting passed to the controller (sometimes post/sometimes get) so I was thinking request would be faster. Since I have never used it I wanted to check what you thought about it first, and see if there was anything wrong, or insecure about using request.
  11. Got it, it was the error handler line. Where I was outputting the span tag's, I forgot to close it so it was throwing the whole form out of wack.
  12. It's a style preference. that can't be it, because news is done the same way and it works. This is simply the way I currently code. If the value is empty (which it's not suppose to be) then return an error, if it's not empty "" then it's got something in it. It can't be that, it's something else I just can't figure out what's causing it.
  13. Look at the login behind the code. the $date, and the $news aren't set yet. That part of the script isn't accomplished yet. I am just looking at the form, and the error handler, that's it for now The form is populated by whatever the person types in. It is initially empty because post isn't populated. It's just a quick way to repopulate the form. They submit it, then the post field comes back on itself and repopulates if they had an error. However in this situation, the initial error checking isn't working.
  14. Yes, it's in the form. So the form is suppose to pass it to the script. It's there in the array but not active in the error handler, and what's wierd is when you submit the form. If you look at the view source there is now a d in the value area for date, but it's not showing in the browser, or as an error, or in the array :S
  15. <?php require_once("../config.php"); ?> <?php if ($_SESSION['controller'] == true) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="css/admin1.css" /> <title>$$$$$$</title> <script language="javascript" type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script> <script language="javascript" type="text/javascript"> tinyMCE.init({ mode : "textareas", theme : "advanced" }); </script> </head> <body id="admin"> <div id="adminwrap"> <div id="adminheader"><h2>Control Panel</h2></div> <div id="adminbody"> <div id="adminleftcol"> <?php require_once("./includes/admin.leftnav.inc.php"); ?> </div> <div id="adminrightcol"> <?php if (isset($_POST['submit'])) { $errorhandler = ""; if ($_POST['date'] == "") { $errorhandler .= "Date Required.<br />"; } if ($_POST['news'] == "") { $errorhandler .= "News Required.<br />"; } if ($errorhandler != "") { echo '<span style="color:red;"'; echo $errorhandler; echo '</span>'; $show = "yes"; } if ($errorhandler == "") { $insert = "INSERT INTO news_cms (date, news) VALUES ('$date', '$news');"; if (mysql_query($insert)) { echo "Success"; $show = "no"; }else { echo "Failed"; $show = "yes"; } } } ?> <h2>New's Entry</h2> <p>Add New new's entries here.</p> <form name="addnews" id="addnews" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label for="date">Date:(any format)</label> <input name="date" type="text" value="<?php echo $_POST['date']; ?>" /> <br /> <label for="news">News</label> <br /><br /> <textarea name="news"></textarea> <br /> <input name="submit" id="submit" type="submit" value="Enter" /> </form> </div> <div id="adminfooter"> </div> </div> </body> </html> <?php }else { header("Location: index.php"); } ?> It's passing the new's but not the date. Actually it is passing the date properly (using print_r) but when I try to detect it using the error hanlding it's not doing anything I replicated this same format thousands of time's, I just don't understand why that one variable isn't passing. It's doing the news properly, but acting like date isn't even there.
  16. Well I have started using classes quite a bit. However I am not ready to move onto classes for queries, not until I understand classes/objects fully. Right now I am using about 2 external classes, and slowly constructing my lists of functions which I will later make into classes. For right now I am just looking for nothing but a pagination class, however, it's not coming along to well. I am going to end up having to pull over my normal style of pagination instead, because I don't have time to play with it right now, if anyone has any pagination classes, or knows of any let me know.
  17. Yes, what is causing the problems is your error settings. The ONLY time the page goes blank is if theres a parse error, or other type of error and you have the error settings cut off. adjust it at the top of the page using error_reporting. If not, then use htaccess, or alter the ini file.
  18. I am trying to find a really, really good pagination class that can be used to display them in multiple way's. Anyway have any they really like, or have created that I could use. I am looking for something that has a lot of features. I always hated pagination, however after looking through classes I have found a lot that will cut down on time. Though I want to try to find one where the way you paginate can be changed around a little bit easier. Does anyone know of a really good one, that they have used.
  19. Has anyone used xoom, if so is it reliable/cheap. If you wanted to use xoom, to pay with paypal.
  20. No, there is not really a way using php that I know of. However there are other things that can be done. For example, I know the owner of PHP freaks has something setup so if any of his site's go down it sends him a page. I don't how this is done, but I know he does it for phpfreaks, and his other site's, so I know there is a way.
  21. No, actually you brought me to a few very strong notices. For one, I realized that there are different type of classifications and I never took the time to really decide. There are sql specific functions, and mysql specific funcitons, and php's mysql functions. I was aware of this but never took the time to really look at the differences, and analyze which are best in what situations. Because of that I am going to sit back and look at some of those, as well as that list. It's going to be a very valuable resource. So in actually you helped a lot, I think I actually went up a whole level with sql/mysql related knowledge thanks to you. I never ever realized those mysql functions existed, because I was always too busy looking at just those sql functions, thanks again for the advice.
  22. Hmm, those are very valid points. I am going to start specifically trying to do that, it makes good since. I normally try to limit them, and set the id's as indexed. However I think I could take that another level, I normally select * instead of selecting what I need. Thanks for the input.
  23. Go to php.net and check the term "wordwrap()" look in the user notes and you will see a lot of functions that do it a lot more affectively than the standard implementation of just "wordwrap"
  24. http://www.google.com/search?hl=en&q=PHP+to+Perl+converter&btnG=Google+Search
  25. I didn't see the whole post, but it seems as if you are trying a little too hard. Use something simple, like. function validateemail($email) { global $errorhandler; // set regular expression to test email if ($email == "") { return false; } $regexemail = "^[A-Za-z0-9\._-]+@([A-Za-z0-9][A-Za-z0-9-]{1,62})(\.[A-Za-z][A-Za-z0-9-]{1,62})+$"; if (!ereg($regexemail, $email)) { // test for formatting return false; } return true; } Instead of eregi. If for some reason the error is still coming I am pretty sure if you check an info page <?php phpinfo(); ?> there is one or more "forbidden" functions, that might be throwing that error. They could also have PHP running in safe mode, and a lot of functions don't work in safemode. However knowing go-daddy they are one of the best and I have never encountered those types of settings, chances are it's something to do with an htaccess file or something somewhere else.
×
×
  • 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.