Jump to content

kjtocool

Members
  • Posts

    187
  • Joined

  • Last visited

    Never

Everything posted by kjtocool

  1. Of course. The problem with that is, I want to get JUST movies that start with A, B, C, etc, and I want an option that is "Other" and includes just movies starting with numbers, etc. Since I need a result set, and since I don't know exactly how many of these movies there are, a simple ORDER BY is not sufficient. The above, is exactly what I was looking for.
  2. I am working on an Alphabetical sort, and am wondering if there is an easier way to handle finding numerical named movies like: "88 Weeks." Currently I have to use something like: $query = "SELECT * FROM myCinema_Movies WHERE (movieName like '0%' or movieName like '1%' or movieName like '2%' or movieName like '3%' or movieName like '4%' or movieName like '5%' or movieName like '6%' or movieName like '7%' or movieName like '8%' or movieName like '9%') order by movieName"; Is it possible to simplify it, or am i stuck using this?
  3. Thanks, did a little testing, seems like the LIKE statement will help a lot, but it seems to only do a test to see if the items in a specific column contain the string given. For example, if the column in the database has "Prom" and you do a LIKE search for porm, you will get no results. Is there a simple way to also test for minor misspelling errors like the above?
  4. I want the user to be able to enter a string, say: "Dog's Play" I have a database filled with various strings like: Dog at Play Monkey Town Dog in Play Doggies Play John and Sally Playground Amy T Dog World What is the best way to utilize PHP and MySQL to return partial and related strings from the database while excluding the irrelevant?
  5. Frickin phpbb I now have to add about 100 lines of code, modify the query to retrieve the hashed password, then send the hashed password and the users password through 4 functions to find out if they match. Really? MD5 wasn't safe enough? Sigh, going from one line to 150 is never fun.
  6. So I make everyone on my site register with my phpbb 3.0.1 forum to use various main site features, and I had been querying the phpbb database to find out the username/password of the user. It seems the password hash has changed from MD5 between 3.0 RC5 and 3.0.1, and now all my php login scripts are busted. Can anyone tell me what the new hash is and how I should modify my code to fix it? The only really relevant code is: <?php $passwordHash = md5($_POST['user_password']); ?>
  7. Heh, yeah, give me whatever you can, I really appreciate the help.
  8. But wouldn't you need to do something like: <img src=<?php echo $widget_image; ?>><?php echo $widget_info; ?></img> Because I just want someone to be able to put: [img=www.linktoimage.com] in their signature, and I want that image to auto generate, or be previously auto generated.
  9. Well, the problem is, I want the image to contain 5 database entries, and I want them all on the same JPG, if possible, otherwise, on a rotating GIF. And I want that to be capable of going into a signature on a forum. I'm not sure I understand what you were suggesting.
  10. Doing a little research, it looks like using GD I can do something like this: http://www.developertutorials.com/tutorials/php/creating-dynamic-text-images-050623/page1.html It's telling me to use the functions: $size = imagettfbbox(12,0,"Fonts/comic.ttf","image string"); $im = imagecreate(abs($size[4]-$size[0]),$size[1]+abs($size[5])); imagettftext($im,12,0,0,abs($size[5]),$black,"/Fonts/arial.ttf","image string"); etc, etc. Can anyone explain this process to me a little better?
  11. I am building a program that utilizes a MySQL database. It will track all the widgets you have used, with a date, name, and various other information about the widget. I would like to be able to have it so that each distinct user has the ability to have an associated image which will be generated using SQL calls to show the last 5 widgets he utilized. Similar to a gamer tag for various Can anyone help guide me toward this?
  12. OK, this code is a bit complicated ... <?php // Do this if user has NOT selected BOTH the start and end date if ($_POST['start_date'] == "" || $_POST['end_date'] == "") { echo "You somehow managed to not enter a date. I didn't think it was possible! Congrats, now enter some dates."; } // Do this if user has selected BOTH a start and end date else { $start_date = $_POST['start_date']; $end_date = $_POST['end_date']; // Get deadline, and create a number with it via array $start_temp = str_split($start_date); $end_temp = str_split($end_date); $start_clean = array(); $end_clean = array(); foreach($start_temp as $value){ if(is_numeric($value)){ $start_clean [] = $value; } } foreach($end_temp as $value){ if(is_numeric($value)){ $end_clean [] = $value; } } $start_date = implode($start_clean); $end_date = implode($end_clean); // Start date is AFTER the end date if ($start_date - $end_date >= 0) { echo "You must select a start date that comes BEFORE an end date."; } // Start date is before end date else { $databaseConnect = mysqli_connect("localhost", "username", "pass", "db") Or die("Unable to connect to the database."); $query = "SELECT * FROM bonanza_weeks"; $result = mysqli_query($databaseConnect, $query); $row = mysqli_fetch_assoc($result); $weekID_array = array(); // Get all week_id's within range while ($row) { // Alter Deadline to fit correct format $weekend_start = $row['weekend_start']; $weekend_temp = str_split($weekend_start); $weekend_clean = array(); foreach($weekend_temp as $value){ if(is_numeric($value)){ $weekend_clean [] = $value; } } $weekend_start = implode($weekend_clean); // Date is inside range if ($weekend_start - $start_date >= 0 && $weekend_start - $end_date <= 0) { $weekID_array[] = $row['week_id']; } $row = mysqli_fetch_assoc($result); } mysqli_free_result($result); $query = "SELECT user_id FROM bonanza_rankings"; $result = mysqli_query($databaseConnect, $query); $row = mysqli_fetch_assoc($result); $userID_array = array(); // Get all user_id's who have played at least 1 week while ($row) { $userID_array[] = $row['user_id']; $row = mysqli_fetch_assoc($result); } mysqli_free_result($result); $average_array = array(); $holdover_average_array = array(); $opener_average_array = array(); $weeks_predicted_array = array(); // Go through each user_id and get scores foreach ($userID_array as $current_user_id) { $average = 0; $holdover_average = 0; $opener_average = 0; $weeks_predicted = 0; $total_weeks = 0; // This will go through each week id foreach ($weekID_array as $week_id) { $query = "SELECT * FROM bonanza_actuals WHERE week_id = $week_id"; $result = mysqli_query($databaseConnect, $query); // Week in range hasn't finished if (mysqli_num_rows($result) == 0) { // Do nothing mysqli_free_result($result); } // Week has had scores calculated else { mysqli_free_result($result); $query = "SELECT * FROM bonanza_predictions WHERE user_id = $current_user_id AND week_id = $week_id"; $result = mysqli_query($databaseConnect, $query); // If the user has no prediction for that week if (mysqli_num_rows($result) == 0) { $total_weeks++; } // User has a prediction else { $row = mysqli_fetch_assoc($result); if ($row['score'] == NULL) { // Do nothing } else { $average += $row['score']; } if ($row['holdover_score'] == NULL) { // Do nothing } else { $holdover_average += $row['holdover_score']; } if ($row['opener_score'] == NULL) { // Do nothing } else { $opener_average += $row['opener_score']; } $weeks_predicted++; $total_weeks++; } mysqli_free_result($result); } } $average = $average / $total_weeks; $average = round($average, 3); $holdover_average = $holdover_average / $total_weeks; $holdover_average = round($holdover_average, 3); $opener_average = $opener_average / $total_weeks; $opener_average = round($opener_average, 3); $average_array["$current_user_id"] = $average; $holdover_average_array["$current_user_id"] = $holdover_average; $opener_average_array["$current_user_id"] = $opener_average; $weeks_predicted_array["$current_user_id"] = $weeks_predicted; print_r($average_array); } mysqli_close($databaseConnect); } } ?> The basic jist of it is that I am trying to create an array with $user_id => $average, etc. But the output is of the print_r statement above is: Array ( [2] => 58.038 ) Array ( [2] => 58.038 [11] => 55.99 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 [609] => 25.953 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 [609] => 25.953 [615] => 28.295 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 [609] => 25.953 [615] => 28.295 [2517] => 55.378 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 [609] => 25.953 [615] => 28.295 [2517] => 55.378 [2809] => 25.267 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 [609] => 25.953 [615] => 28.295 [2517] => 55.378 [2809] => 25.267 [2830] => 23.905 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 [609] => 25.953 [615] => 28.295 [2517] => 55.378 [2809] => 25.267 [2830] => 23.905 [3200] => 84.528 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 [609] => 25.953 [615] => 28.295 [2517] => 55.378 [2809] => 25.267 [2830] => 23.905 [3200] => 84.528 [3323] => 25.932 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 [609] => 25.953 [615] => 28.295 [2517] => 55.378 [2809] => 25.267 [2830] => 23.905 [3200] => 84.528 [3323] => 25.932 [4150] => 74.702 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 [609] => 25.953 [615] => 28.295 [2517] => 55.378 [2809] => 25.267 [2830] => 23.905 [3200] => 84.528 [3323] => 25.932 [4150] => 74.702 [4156] => 83.031 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 [609] => 25.953 [615] => 28.295 [2517] => 55.378 [2809] => 25.267 [2830] => 23.905 [3200] => 84.528 [3323] => 25.932 [4150] => 74.702 [4156] => 83.031 [4317] => 24.836 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 [609] => 25.953 [615] => 28.295 [2517] => 55.378 [2809] => 25.267 [2830] => 23.905 [3200] => 84.528 [3323] => 25.932 [4150] => 74.702 [4156] => 83.031 [4317] => 24.836 [6035] => 80.994 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 [609] => 25.953 [615] => 28.295 [2517] => 55.378 [2809] => 25.267 [2830] => 23.905 [3200] => 84.528 [3323] => 25.932 [4150] => 74.702 [4156] => 83.031 [4317] => 24.836 [6035] => 80.994 [6131] => 24.307 ) Array ( [2] => 58.038 [11] => 55.99 [33] => 84.26 [35] => 80.444 [49] => 26.707 [66] => 84.334 [79] => 53.419 [89] => 51.245 [103] => 48.34 [105] => 28.55 [110] => 26.69 [113] => 26.672 [126] => 29.363 [133] => 28.553 [149] => 27.837 [166] => 27.486 [182] => 23.992 [187] => 27.946 [189] => 26.17 [275] => 80.967 [280] => 51.776 [476] => 23.373 [509] => 50.015 [539] => 48.316 [578] => 28.933 [607] => 28.346 [609] => 25.953 [615] => 28.295 [2517] => 55.378 [2809] => 25.267 [2830] => 23.905 [3200] => 84.528 [3323] => 25.932 [4150] => 74.702 [4156] => 83.031 [4317] => 24.836 [6035] => 80.994 [6131] => 24.307 [9574] => 27.391 ) So as you can see, it is printing an array within an array, within an array, etc. I can't figure it out. Each user ID should only show up once, but this code is nesting arrays within arrays. Help?
  13. It now prints out: Today: 20080118133543 Deadline: 20080118040100 Today - Deadline =: 93443 This seems to work, since it just creates two giant numbers. Then I can do a subtraction ... Deadline - Today, and then create a variable ... if that variable > 0 then the deadline hasn't passed, and they should be able to predict. If it's < 0, then it's the opposite. I think this will work. Thanks for your help, I'm going to go do some tests!
  14. Done. I echoed out this: It returned: echo "Today: " . $today_date . "<br />"; echo "Deadline: " . $latest_prediction_deadline . "<br />"; $some = $today_date - $latest_prediction_deadline; echo "Today - Deadline =: " . $some . "<br />"; Today: 2008-01-18 13:24:15 Deadline: 20080118040100 Today - Deadline =: -20080118038100 Should note, $today_date is still gotten by getDate(), not timestamp(). If you want me to try it with timestamp, I can, but I need to know what letter equals minutes, since in the example you gave me, you used (m), which is Months. The answer seems to be 3hours 81minutes 0seconds ... I have no idea how it came up with that, I expected it to be 20080118094315
  15. Sigh, I just don't understand why you think the time stamp will make a lick of difference. Sure, I can format it however I want, but I can do the same thing with getDate(), albeit with a bit more work. I'll go ahead and make the modification, but it's only going to effect the 'Today's Date' variable. I can't add a timestamp for Prediction deadline, since it's a date in the future. I still strongly believe the problem is related to me appending a string to the date, then storing it as datetime in MySQL, not with the formating associated with getDate(), which works fine. How do I fix the timestamp so that it shows minutes not months like it currently does. In the example you gave, you used months (m) twice.
  16. Heh, As I said above, I have tried that as well, it resulted in the same problem. They really don't have to be two digits, when MySQL stores it as a datetime, it auto appends the 0's.
  17. I just tried and echoed the code you gave, it fed back: timestamp: 2008-01-18 12:01:32 It seems you duplicated m twice, so the month is showing up as minutes. Even if fixed, it still is in the same format of the timestamp I crated using getDate(), so I don't see how that would solve the problem. I personally believe something is wrong with the comparison itself, because I think that the time isn't being stored properly for some reason in the database. I wonder if it's maybe because of this code I use: // There is a form allowing the user to specify the date, it comes across in the following format: 2008-01-18, or, YEAR-MM-DD $prediction_end = $_POST['prediction_end']; // I then append a time to the end of this date, creating the format: 2008-01-18 4:1:00, or, YEAR-MM-DD H:M:SS $prediction_end .= " 4:1:00";
  18. So instead of getDate, you think I should use time()? That might make the code simpler, but is there any fundamental difference that would change the outcome?
  19. Yes, it's at ET. Getting Today's Date would obviously get the server time of the page load, and it's showing up ET.
  20. **Please Note: The code is 100% functional and working except for the comparison issue described below.** Problem I am trying to compare two dates: today's date and the prediction deadline (Each Friday at 4:01 am ET). The comparison works totally perfectly throughout the week, but each Friday at 12:00 am ET, it falsely says that the deadline has passed (when it should stay open another 4 hours until 4:01 am ET). The value is stored in a MySQL database as a datetime variable. There is an admin section where I add a new 'week'. Each week is stored in a MySQL database, and each week has a 'Prediction Deadline' column. Here is how I set that date: <?php // There is a form allowing the user to specify the date, it comes across in the following format: 2008-01-18, or, YEAR-MM-DD $prediction_end = $_POST['prediction_end']; // I then append a time to the end of this date, creating the format: 2008-01-18 4:1:00, or, YEAR-MM-DD H:M:SS $prediction_end .= " 4:1:00"; ... other code ... //Here is the query to add a new week to the database, including the $prediction_end column $query = "INSERT INTO bonanza_weeks VALUES (NULL, '$prediction_end', '$weekend_start', '$weekend_end', '$movie_1_name', $movie_1_opener, '$movie_2_name', $movie_2_opener, '$movie_3_name', $movie_3_opener, '$movie_4_name', $movie_4_opener, '$movie_5_name', $movie_5_opener, '$movie_6_name', $movie_6_opener, '$movie_7_name', $movie_7_opener, '$movie_8_name', $movie_8_opener, '$movie_9_name', $movie_9_opener, '$movie_10_name', $movie_10_opener)"; // The above query works fine, and the week is properly added to the database. The date looks like this in the database: 2008-01-18 04:01:00 // The prediction_deadline column in the database is of type datetime ... other code ... ?> You may be asking yourself, why not use: $prediction_end .= " 04:01:00"; ... I have, it resulted in the same problem. So now the week is added to the database, and the prediction deadline stored as a datetime variable. I next have a page where I do a comparison, here is the relevant code: <?php // Here I generate today's date, which I will compare to the value in the database $today = getdate(); $today_year = $today['year']; $today_month = $today['mon']; $today_month = str_pad($today_month, 2, "0", STR_PAD_LEFT); $today_day = $today['mday']; $today_day = str_pad($today_day, 2, "0", STR_PAD_LEFT); $today_hours = $today['hours']; $today_minutes = $today['minutes']; $today_seconds = $today['seconds']; $today_date = $today_year . "-" . $today_month . "-" . $today_day . " " . $today_hours . ":" . $today_minutes . ":" . $today_seconds; // The following echo returns: 2008-01-18 12:24:30 echo $today_date . "<br />"; ... some code ... // I get the deadline value from the database $latest_prediction_deadline = $row['prediction_end']; // The following echo returns: 2008-01-18 04:01:00 echo $latest_prediction_deadline . "<br />"; // Here is a comparison I did, trying to subtract one date from another. It echoed "0" $some = $today_date - $latest_prediction_deadline; echo $some . "<br />"; ... code ... // Here is the comparison: if ($today_date < $latest_prediction_deadline) { more code } ?> Now, the comparison normally works fine, but seems to only compare correctly for the date, and not the time. I don't understand what I'm doing wrong, could it have something to do with the way I am building today's date? The way I append the time onto the POST value of prediction deadline? I'm really lost. ???
  21. I am writing a function which takes two arrays filled with movie name > movie gross pairs. The arrays are in no order, and the function will return a score for each movie, comparing the correct values in each array. I am not having a problem with the function, it works fine. But the line with comments above it is throwing an error when I try and add a new value to the array. <?php function get_user_scores($user_array, $actuals_array) { $array = array(); foreach ($user_array as $user_name => $user_gross) { foreach ($actuals_array as $actual_name => $actual_gross) { if ($user_name == $actual_name) { $difference = $user_gross - $actual_gross; $absolute = abs($difference); $score_unformated = $absolute / $actual_gross; $score = 1 - $score_unformated; $score = $score * 100; $score = round($score, 3); if ($score < 0) { $score = 0; } // This line (below) is throwing an error. $array[$user_name] = $score, $actual_gross; } } } return $array; } ?> Error: Parse error: syntax error, unexpected ',' in /home/worldofk/public_html/bonanza_results.php on line 269 Shouldn't this be a legal addition to an associative array?
  22. Nah, this is just code I wrote to simplify and explain the issue, the real code is much more complicated, but working. As I said, some comparisons work correctly, others do not. It should also be noted that the time is stored in a mysql databae by the following: <?php // Gives the date $prediction_end = $_POST['prediction_end']; // Adds the time $prediction_end .= " 04:01:00"; ?>
  23. I am trying to compare two dates like so: <?php if ($todays_date < $prediction_deadline) { echo "do this"; } else { echo "do that"; } ?> I have echoed out both variables at before the comparison, and have done so at various different times. Below is some of the times I've echoed the variable out, and the comparison's result: Today's Date: 2008-01-11 03:17:46 vs Prediction Deadline: 2008-01-11 05:01:00 - Comparison prints "do that" Today's Date: 2008-01-11 01:22:14 vs Prediction Deadline: 2008-01-11 04:01:00 - Comparison prints "do that" Today's Date: 2008-01-11 12:23:56 vs Prediction Deadline: 2008-01-11 10:01:00 - Comparison prints "do that" Today's Date: 2008-01-11 12:24:54 vs Prediction Deadline: 2008-01-11 12:29:00 - Comparison prints "do this" Today's Date: 2008-01-11 12:26:17 vs Prediction Deadline: 2008-01-11 14:29:00 - Comparison prints "do this" I don't understand why the first two comparisons are coming up faulty? Could it be because of the 0 before the hour?
  24. I love this forum for php, mysql, etc, but am looking for a more dedicated support forum related to Java. Anyone know of any other than the actual sun boards?
×
×
  • 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.