Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. Edit: to match your edit...
  2. Your original code would have needed to start with $t=0 to get all the row(s) or use <= for the comparison.
  3. You are not doing anything in your code to relate the comment with the corresponding topic, so of course there is no relationship. Your comment.php code needs to pass the $_GET['id'] value to the reply.php code and reply.php needs to store the topic id in the `post` table with the comment. You also need to STOP repeating the same query 3-4 times on one page. Just execute the query ONCE and then access the columns as you iterate over the data. You have a ton of excess code that makes it harder to see the forest (goal of the code) for the trees.
  4. If you search the forum for the phrase 'doesn't work', you will find that it means nothing to us because we are not standing right next to you and don't know what you tried, what your complete relevant code is that duplicates the problem, or what you saw in front of you. Programming is an exact science. Computers only do exactly what their code and data tells them to do. We can only help when we have specific information.
  5. Have you checked if your data that relates the comment with the correct topic is correct in your database? Having someone observe the final incorrect result, doesn't help pin down where the problem is occurring at. Your code that accepts and stores the comment could be incorrect or your code that gets and displays the topic and comments could be where the problem lies. You need to pin down at what point in the entire process your code and data is doing what you expect and at what point they are not. I can guarantee that the problem lies somewhere between those two points.
  6. ^^^ That whole statement means zero to us because we are not standing right next to you and so don't know what the 'it' is that you keep mentioning. What ever 'it' is, please don't put SELECT queries inside of loops. You will end up with a game that performs so poorly that only about 5 concurrent people can play it before it slows down to the point that no one will want to play it.
  7. No one said to loop while $x is == 5. Those are logically two different things. You might want to loop while $x is < 5
  8. Are you browsing to the URL of your page? You should be using an address like - http://localhost/your_page.php in your browser. Edit: You must also use full <?php tags n any .php files that you are including.
  9. Make your while(){} loop only for the mysql data. Increment the $x variable inside the while(){} loop. Add another while loop after the end of the first while loop that loops until $x is == 5. The second while loop will output anything you want to finish the row.
  10. Change all your short opening lazy-way php tags <? into full normal opening <?php tags.
  11. The output is coming from index.php. Check it for the BOM characters.
  12. You are sending output to the browser on line 10 (and probably lines 1-9) of your index.php file.
  13. I'm wondering why you removed the single-quotes from around the literal date value? Without them, you have a math expression: 2012 minus 01 minus 24 = 1987
  14. The error is from the series of empty comma's ,,, If you are listing a field in the query, you must supply a value of some kind that is appropriate for the type of field.
  15. Define: manually splitting then processing to obtain the required CSV files Why and what are you splitting the data for? What processing are you doing? Why and what are the 'required' CSV files?
  16. <?php if($last_heading != $new_heading){ .... } // the sub-heading (time) logic would go here, using an if($last_subheading != $new_subheading){} similar to that for the heading logic // the code to output just the event title would go here
  17. You have a form with the data that you want, you need to process that form data and make an email body with the field names and values. Where exactly are you stuck at in doing that? To see what your form is sending, use the following line in your form processing code - echo '<pre>',print_r($_POST,true),'</pre>'; Your code is horrifically formated. You need to both remove the excess white-space in it and validate the resulting HTML page. Your switch/case logic can be greatly simplified by using a 'lookup' table. Add something like the following to your 'configuration' data - <?php // lookup table of product codes and product categories $product_lookup["BH"] = "Vehicle Accessory"; $product_lookup["DG"] = "Dog Guard"; $product_lookup["RB"] = "Vehicle Accessory"; $product_lookup["XD"] = "General Accessory"; $product_lookup["XL"] = "General Accessory"; $product_lookup["WG"] = "Window Grille"; $product_lookup["BT"] = "Boot Rack"; $product_lookup["BR"] = "Bike Rack"; $product_lookup["LB"] = "Roof Bar"; $product_lookup["LR"] = "Roof Rack"; $product_lookup["SK"] = "Ski Rack"; $product_lookup["VR"] = "Van Racking"; Then your switch/case logic will simply become the following and you won't need to alter the body of your code to change, add, or remove any of the categories - <?php if(isset($product_lookup[$strPrefix])){ $strProdType = $product_lookup[$strPrefix]; } else { $strProdType = "The product type for this item could not be found"; } You should also use arrays for the repeating form fields so that you can simply iterate over the repeated fields using a foreach loop. See the following - <?php //create hidden form names and values containing product details echo "<input type='hidden' name='Car_Make[$frmCount]' value='". htmlspecialchars($row['Car_Make']) ."'>"; echo "<input type='hidden' name='Car_Model[$frmCount]' value='". htmlspecialchars($row['Car_Model']) ."'>"; echo "<input type='hidden' name='Product_Make[$frmCount]' value='". htmlspecialchars($row['Prod_Make']) ."'>"; echo "<input type='hidden' name='Product_Model[$frmCount]' value='". htmlspecialchars($row['Prod_Model']) ."'>"; echo "<input type='hidden' name='Product_Type[$frmCount]' value='". $strProdType ."'>"; echo "<input type='hidden' name='Product_REF[$frmCount]' value='". $row['Prod_REF'] ."'>"; echo "<input type='hidden' name='Product_Quantity[$frmCount]' value='". htmlspecialchars($row['quantity']) ."'>"; $bob = number_format(calcVAT(htmlspecialchars($row['Price_ExVat'])), 2); echo "<input type='hidden' name='Product_Price[$frmCount]' value='$bob'>";
  18. Why would you explode data, only to implode it back to what it started as?
  19. The day part of your literal date value MUST have a leading zero, to give it two digits, for the greater-than comparison to work correctly.
  20. Your database table is laid out like a spreadsheet. That wastes storage, takes more code, and more complicated queries to manage or retrieve the data. The inventory table should only have id, user_id, and weapon_id columns (and perhaps a quantity column if you can have more than one of each weapon.) You should have a separate table that holds the definition of all the weapons. It would have the id, type, and name (and any other characteristics for each weapon.) The inventory table would only have rows for actual weapons in the inventory. When a user adds a weapon to his inventory, you would add a row to the inventory table (or increase his quantity of that weapon if he can have more than one and he already has at least one.) When a user looses/uses a weapon, you would delete the row for that weapon (or decrease his quantity of the weapon if he had more than one to start with.) Doing this will save a TON of code. All the repeated code you posted, that only varies in the weapon type, can be replaced by one query and a loop that outputs the appropriate weapon type heading every time the weapon type changes.
  21. Your $c variable is likely a mysql connection link resource and is not part of the LIMIT clause in the query. Please use meaningful names for variables or post all the relevant code.
  22. There's a reason someone with a huge number of posts suggest that line of code. It is relevant to the problem you are trying to solve and it would have shown you what the value is that you would need to use in your comparison logic.
  23. var_dump($subscription_type);
  24. The date() format specifier - 'dd-mm-YY' produces 2222-1010-20122012 for today's date. Since you want this to be year neutral, you can just compare the month number and day number (with leading zero's) and with the month first (most significant digits) and day second (least significant digits.) However, since one of the date ranges spans the end of one year/start of next, you would need to take into account the date rollover. The easiest way, since you are hard-coding the dates anyway, would be to break that date range up into '12-23' to '12-31' and '01-01' to '02-24'
  25. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=352271.0
×
×
  • 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.