Jump to content

akitchin

Staff Alumni
  • Posts

    2,515
  • Joined

  • Last visited

    Never

Everything posted by akitchin

  1. the most likely cause of the error is that $table is not being defined in the page that it isn't working on. is $table being set before the script, or is it being set in load_data.php?
  2. i would guess that there's some sort of template system that should be processing that code, but isn't. we'll need more details - for example, have you changed anything in the last week? moved files, deleted files, added files? are there any other sections of the site that use the <++ syntax?
  3. it means that you've forgotten a semicolon on the line above, so when PHP reaches line 69, it's wondering "just what in tarnation is going on here? this shouldn't be a new line!" if you ever have trouble finding an error on a line that is referenced in an error, have a look at the line above - that's the most likely location of the error.
  4. it's looking like you'll need a multi-dimensional array here. use the group number as one key, and the input number as the second key: <input name="group[1][1]" type="text" /> <input name="group[1][2]" type="text" /> <input name="group[1][3]" type="text" /> <input name="group[2][1]" type="text" /> <input name="group[2][2]" type="text" /> <input name="group[2][3]" type="text" /> <input name="group[3][1]" type="text" /> <input name="group[3][2]" type="text" /> <input name="group[3][3]" type="text" /> to traverse through each group, you can use one foreach(), and to traverse through the inputs in each group, you can use a second foreach(): foreach ($_POST['group'] AS $group_number => $input_array) { echo 'this is group '.$group_number.':<br />'; foreach ($input_array AS $input_number => $input_text) { echo 'input number '.$input_number.' has a value of '.$input_text.'<br />'; } } give that a shot - just running that code should give you an idea of how foreach() and arrays work.
  5. my first suggestion would be instead of storing the result in the format you mentioned (ie. 2:0), store it in two separate fields as "result_left" and "result_right" as integers (name them whatever you want). this will make calculations much easier, because otherwise you need to split the string up before performing the calculation. it's actually not a bad idea to calculate and store the profit in a column in the placed_bets table, since this will allow you to run more straightforward queries on the table to generate those ranking tables and avoid selecting unnecessary data. the best time to calculate is probably when you input the result. you can either store "profit" in the placed_bets table, or you can make a separate table with just the userID, the betID, and the profit. it's probably easiest to put it in the placed_bets table. the calculation should be relatively straightforward. you can simply run an UPDATE query that will update all placed_bets with a matching BettingOfferID to the result you've just input: UPDATE Placed_Bets SET profit = CASE WHEN (SELECT result_left - result_right FROM Betting_Offer WHERE BettingOfferID = '$variable-here') > 0 AND (Selected_Tip = '1' OR Selected_Tip = '1X') THEN Odds_of_Selected_Tip * Stake - Stake CASE WHEN (SELECT result_left - result_right FROM Betting_Offer WHERE BettingOfferID = '$variable-here') = 0 AND (Selected_Tip = 'X' OR Selected_Tip = '1X' OR Selected_Tip = 'X2') THEN Odds_of_Selected_Tip * Stake - Stake CASE WHEN (SELECT result_left - result_right FROM Betting_Offer WHERE BettingOfferID = '$variable-here') < 0 AND (Selected_Tip = '2' OR Selected_Tip = 'X2') THEN Odds_of_Selected_Tip * Stake - Stake ELSE -1 * Stake END WHERE BettingOfferID = '$variable-here' this is a generic UPDATE query that just implements your calculation. if you want a less cumbersome-looking query, you can always do result_left - result_right in PHP after INSERTing it, and run the appropriate individual query: if ($_POST['result_left'] - $_POST['result_right'] > 0) { $query = "UPDATE Placed_Bets SET profit = IF(Selected_Tip = '1' OR Selected_Tip = '1X', Odds_of_Selected_Tip * Stake - Stake, -1 * Stake) WHERE BettingOfferID = '$variable-here'"; } elseif ($_POST['result_left'] - $_POST['result_right'] == 0) { } (you get the idea) hopefully this helps you get a picture of what's involved here. you can then use functions like SUM() and AVG() on the profit column GROUPed by userID to play around with stats when SELECTing the data for ranking tables.
  6. the issue is in your use of array items in double-quoted strings. PHP is expecting a simple variable when you interpolate, and an array item's notation will throw it off. in order to incorporate them, this: echo "Strand: $row['strand']"; echo "Score: $row['score']"; echo "attempts: $row['2']"; should be: echo "Strand: {$row['strand']}"; echo "Score: {$row['score']}"; echo "attempts: {$row['2']}"; EDIT: to help you avoid this in future, a parse error of "expecting" something means that PHP came across incorrect syntax usually. look around for unpaired braces, parentheses, brackets, and also check for semicolons.
  7. depending on your proficiency with PHP, the solution is similar in SQL. a section that might do wonders to help you through this is the functions and operators portion of the MySQL manual. in order to help you better, can you offer more details with regards to the table columns? i was under the impression results and bet parameters were in the same table, but you've just mentioned result will be in a separate table.
  8. ... okay? if it's solved, care to share with the rest of the class what the problem was?
  9. then my guess is you're trying to run the INSERT with a user whose userlevel is 1. in that case, no $table is defined, and the INSERT query will obviously fail. if that isn't the case, it might be worth making sure that you didn't make any typos when defining the table's fields.
  10. are you trying to do this with MySQL queries, or is this a calculation you need to perform prior to inserting the bet into the database?
  11. the simple answer is exactly what the computer is telling you: 'poster' doesn't exist in the table you're trying to run the INSERT query on. are you sure it exists in both the 'comments' and the 'ucomments' tables?
  12. i have google maps, and that's about it (blackberry curve). it's a company phone so i avoid putting anything that uses an exceptional amount of bandwidth, and i'm also under the umbrella of the company's proxy, so i can't use a number of the other handy apps (like google chat or facebook). as for messaging, i use blackberry messenger just to keep in touch for free with friends back home.
  13. Then either he started late, he is really slow, or he is in some sort of obscure subfield of physics. not necessarily - a lot of physics Ph.D's take a hell of a long time, regardless of their thesis area. it's especially true if he went the B.Sc.-M.Sc.-Ph.D. route (rather than straight B.Sc.-Ph.D.).
  14. i don't suppose you've thought about passing it a test string to see? substr() won't pad the string; if the length is longer than the string, it will simply return the string.
  15. each set of matches will be its own array within the parent array. therefore, as xangelo points out, you need to specify the key from one array as the first key for the second array. to use your specific variables: foreach ($icons AS $top_key => $icon_info) { echo '<tr><td>'.$icon_info[1].'</td><td>'.$descs[$top_key][1].'</td></tr>'; } again, everyone has contributed piecemeal to this issue to help solve it - just thought i'd give an example using the variables you've already shown us. often times the best way to know how to access your arrays is to print_r() them as nadeemshafi has pointed out so that you can visualize them.
  16. You have most likely just solved my dilemma. I am somewhat inexperienced with nested pages, as I have only built one site previously and it was years ago. I will give this a try and update for reference to others. with nested pages (or included sections), you will usually want to have the "container" file hold all the parental HTML data such as the html, head, and body tags. the included files themselves should only contain data pertaining to the physical section of the site they are meant to represent (if that makes sense).
  17. you could select the sum directly: SELECT (y1 + y2) AS yardsTotal FROM tbl_courses WHERE courseID = $id after running the query and grabbing the result, 'yardsTotal' should contain the sum.
  18. it's because you're opening/closing HTML tags several times in the two files. is there a reason why they're standalone HTML pages, and yet one is being included within the other?
  19. what i mean is it's too much like a stock photo, but that's probably just personal bias.
  20. no - in those cases, the developer INTENDS to exit the string in order to append the variable's value into the string. have a google for a PHP concatenation tutorial, as it should help you clear all this up and will help with future string issues too. it can be tricky, but once you have it down, it's down.
  21. those are escaping backslashes. since the string has been delimited by single quotes, any single quotes that you want to put INSIDE of that string need to be escaped, otherwise PHP thinks it's reached the end of the string. for example: $string = 'He said \'I want to go to your house.\' very loudly.'; echo $string; would output: He said 'I want to go to your house.' very loudly.
  22. it's assigning a statement to the $define variable, which i assume is later evaluated as PHP. the statement is just a definition of a constant with the name PRODUCT_NAME_productname and value of whatever strip() does to $product['name'].
  23. akitchin

    Query ?

    from the mysql manual, the LENGTH() function returns the string's length in bytes, not in characters: LENGTH() in MySQL manual try using CHAR_LENGTH() and see if that fixes your issue. otherwise try actually echoing length in each iteration to see what it contains.
  24. are the dates being stored as a comma-delimited list, or are they listed individually in the dates_table?
  25. i think you'll need to start with a basic tutorial about PHP itself before you delve into this sort of thing. the three lines you posted above are exactly how you'd include a file from above the web root with PHP.
×
×
  • 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.