Jump to content

blurredvision

Members
  • Posts

    59
  • Joined

  • Last visited

    Never

Everything posted by blurredvision

  1. Thanks guys. I used Ken's script to great success, and I'll dissect it to implement it into my knowledge.
  2. I'm needing to create links to bring back the previous month and year in just their numbers. I think it has to be done using something like mktime(), but I'm not at all familiar with it. I'd like the cleanest possible solution, so that's why I'm asking you guys for help. Today is June 1st, 2009. Or, 6-2009. I'd like a quick variable that will bring me 5-2009 (ideally, the month number and year would be separate variables). So in my perfect world, I'd end up with $prev_month = 5; and $year = 2009;. If today were January 15th, 2009, I'd want to end up with $prev_month = 12; and $year = 2008;. Pretty simple, but I don't have any idea how to do it. Do I use mktime(), or can I do some kind of date('n') -1;? I appreciate the help and learning!
  3. I have a MySQL table that has a column for dates, and they are in this format: YYYY-MM-DD The column has the DATE data type. The database will always have dates older than today, but will only have at most 14 dates into the future for certain events. What I'm wanting to do is populate a drop down box in one of my forms that will only show today's date along with any dates forthcoming. Dates older than today I do not want. So, for example, today is 2009-05-29. I have a column with the following dates: 2009-05-21 2009-05-23 2009-05-28 2009-05-31 2009-06-02 2009-06-04 2009-06-07 From my explanation, I only want to bring back events that may happen today, as well as any future event dates. What is the best way to go about this? Let's just say that having the event dates in this format is the ONLY way that they can be entered into the database, so anything I do will have to use the above example format. I appreciate any suggestions.
  4. Figured out what I was doing wrong. I was completely forgetting to pass the $value into the function. What a stupid oversight. I was so stuck on trying to find through google if it was correct syntax or not that I didn't look at other factors. Thanks flyhoney, sorry to waste your time.
  5. There is an underscore. Other than that, just letters and a single number. I'm getting part of the string through a function argument, then concatenating a number on to the end. Maybe that's messing with it somehow?
  6. It's definitely a string. I've even echoed the variable to make sure it's showing how I want it, and it is. The cookie just doesn't create. Is my syntax correct?
  7. I have a cookie that I'm setting like such: setcookie("cookiename", $value, time()+3600*24*5); That works perfectly fine. However, I'm now wanting to create my cookie in a different way, by using a variable to set the name of the cookie. Here's what I'd like to do: setcookie($cookie1, $value, time()+3600*24*5); I cannot get that work. Can you not use a variable to set the cookie name, or is my syntax wrong?
  8. I have a project where I'm needing to change the value of an already existing cookie, but I have a set expiry date that I don't want to change. For example, I have a cookie that has a value of 'car', and is set to last for one hour. setcookie("cookie1", "car", time()+3600); In 20 minutes, I will want to change $_COOKIE['cookie1'] from 'car' to 'truck'. BUT, I want to make sure that the cookie will still cease to exist in 40 minutes and not reset back to an hour when I update the cookie with a new value. How do I do this, or can I do this? I've not had much experience with cookies, so thanks for any learning .
  9. I haven't quite learned expressions yet, so I was hoping somebody could quickly give me the right to code to check a variable for the absence of a period. Thanks!
  10. Currently, I'm pulling a column from a table in mysql based on whether a user is active or not. If a user is active, then it will return a value from a column. I'm wanting to check against each value in the array that is created, and if none of them match what I'm looking for, then I want to echo some text. Here's what I've written, but I do know that it's wrong where I'm trying the IF function. I'm posting this just to kind of show you what I'm trying to do, and hopefully you guys can show me what the correct syntax is to check against the entire array. I tried doing a WHILE and running through the array, but it obviously would echo the contents multiple times for however many keys were in the array. EDIT: The $matchups array is one that is created before getting to this block of code....this block of code is in a while loop, just to give you some perspective. $query = "SELECT team,gamertag,active_status FROM user"; $queryresult = mysqli_query($dbc, $query) OR die(); $hpu = mysqli_fetch_array($queryresult); if ($matchups['active_status'] == 1) { if ($matchups['opponent'] != $hpu['team']) { echo '<span class="enterstats">'; echo '- ' . $matchups['team'] . ' (' . $matchups['gamertag'] . ') vs ' . $matchups['opponent']; echo '</span><br />'; } } Thanks for any advice!
  11. EDIT: Nevermind, figured out what I was doing wrong. I have a leaders table on my site that pulls data from a field in my database. I limit it to pulling the top 5 in a descending order. The field is set up to be a TINYINT (not unsigned) with 3 characters. Integers are stored as, for example, 5 for a positive number, -5 when it's a negative number. Pretty simple stuff. So I have my query: $leadersquery1 = "SELECT gamertag_id,turnover_ratio FROM league_leaders WHERE season=$currentseason ORDER BY turnover_ratio DESC LIMIT 5"; At the moment, it should be pulling the following: 4, 3, 1, 0, 0. However, it's only pulling the 4, 3, and 1, and it's not showing the 0's. Am I glancing over something, or do I need to provide more info? I've also tried setting a column type of FLOAT, but it simply does the same thing.
  12. Well, this worked perfectly fine, so I think I'll go with it. Thanks iceblox!
  13. Sorry, completely forgot the query . This is the one for the total offensive stats. $leadersquery1 = "SELECT gamertag_id,total_offense FROM league_leaders WHERE season=$currentseason ORDER BY total_offense DESC LIMIT 12"; $leadersrun1 = mysqli_query($dbc, $leadersquery1);
  14. http://img401.imageshack.us/img401/213/leadertablenx3.jpg
  15. I have a list of stat leaders on my webpage, and they are ordered by either ASC or DESC. All but 1 of the rows returned are 4 digits, that lone one being 3 digits. The easiest way to explain is just to show you: example As you can see, it's putting the 3-digit return on the wrong side of the order. Why would it be doing this, and what would I need to do to fix it?
  16. I have quite a large form that returns a few dozen values through the POST array. The only way I've ever tried to prevent injection attacks is applying the real_escape_string function to individual variables. Can I simply do this to the entire POST array, then use associative values to input into the database?
  17. I'm trying to do something that I've never done before, and I cannot figure out the logic of how to get what I'm wanting. So, hopefully one of you PHP masters can help me out with the code, and maybe make a couple of pointers so I can learn to do this. I have a site and MySQL database that is keeping track of stats of games. The stats of each individual game are stored into two different tables...one table for the hometeam stats, and one table for the awayteam stats. I'm wanting to pull the stats from certain columns/fields from each table for a particular team. Each team's games will obviously be in one table or the other, since they are sometimes the home team, sometimes the away team. So let's say I'm wanting to pull a team's total offensive yards from each game it has played. In the end, each team will ultimately have around 6 rows pulled from the hometeam table, and another 6 from the awayteam table. Then, I'm wanting to add each game's total offensive yards to give a total of the team's offensive yards for the season. Can anyone help me get started on this? I'm assuming it will require some multi-dimensional arrays, something I've yet to mess with in PHP learnings. Thanks for any help you guys can provide!!
  18. Well, the reason I don't think it is is because everything uses the same code and the same loop. Why would it return the value correctly 90% of the time, but return it incorrectly 10% of the time, when I visually verify that the value is correct in the database? This just baffles me. I'll take another look at it and do your suggestion, we'll see what happens.
  19. Since the project I'm working on is too big to post here, I'm just wanting to get an idea of what can cause this, since I'm stumped. Basically, I have one piece of code about 150 lines long that handles pulling a series of stats from two different tables (one are home team stats, the other away team stats) of a MySQL database. I created it and tested it, and everything looked like it work beautifully. However, I started to notice that out of the 70 or 80 games I had entered so far, there are 5-10 instances where the pass attempts value is just duplicating what the pass completions shows. With 90% of the games, the pass completions and attempts show correctly, but with the other 10%, the pass attempts are the same as the pass completions. So I thought it was just an error on my entry, but after checking the games I've noticed this on, the database shows the correct values. The database values are correct, the code is correct, 90% of the time it's working fine. It's just these few games that show incorrectly, and it's only the home team. Can anyone give me any clue as to why this happening if everything is correct on my end? I've spotted this problem on two different computers, and I've also used different browsers, so I'm pretty sure the problem is with the database and not any kind of caching or something like that. There are only 5 tables, all MyISAM. Thanks for any insight on what to read up on or what to look for.
  20. I have a listing of percentages, and the calculation is a simple divide this number by that number. However, I want to return the decimal plus 3 digits afterwards, for example, I'd want it to show (without the quote of course) ".800". Instead, it shows ".8". Is there a simple way to have it show 0's on the end of these decimal numbers?
  21. That single link has helped me tremendously. I taught myself using a combination of Larry Ullman's PHP6 and MySQL 5 Visual QuickPro book and sites like w3schools and tizag.
  22. I'm familiar with mysqli_fetch_array when returning values and such, but for the first time, I'm needing to use the COUNT(*) function in mysql. Here's my code: $winsquery1 = "SELECT COUNT(*) FROM hometeam_stats WHERE gamertag_id='{$standings['gamertag_id']}' AND season='$currentseason' AND win_loss=1"; $runqueries1 = @mysqli_query($dbc, $winsquery1); Usually, I would just set up $runqueries1 with the fetch array and go from there. But how do I simply extract the number that my query should hopefully be getting?
  23. So what do you mean "one of the other queries"? There are only 2 queries in this script that would be run, and it's not getting to the second one because the first one is failing. The config.php file that's required at the very top works fine for all my other pages that have similar queries. ???
×
×
  • 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.