Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. Assuming that you don't have a fatal parse error in your main file, you can add the following two lines immediately after your first opening <?php tag to set those values in your script - ini_set("display_errors", "1"); error_reporting(-1);
  2. Unless the variable $something contains the name of an actual property of the class.
  3. Do you have error_reporting set to E_ALL and display_errors set to ON so that php detected errors would be reported and displayed?
  4. I going to assume that you are including the maincontent.php file into index.php? That includes the php code that is in maincontent.php ('content' just happens to be the path to where php can find the maincontent.php file at) into index.php. When the code is finally executed, the code that was included from maincontent.php is part of index.php and is being executed as part of index.php. Looking at this a slightly different way. The browser requested index.php. It is also the browser that requests the image in the src="..." attribute. The browser has no idea that maincontent.php even exits because the browser only sees the HTML that your index.php file outputs. Any relative URL's in an <img> tag are relative to the page they are on, in this case index.php.
  5. If the form method='get', only the form data is included on the end of the URL. In this case, the only way you can get it to work is by using hidden fields.
  6. For your index.php page in the prototype folder to display an image in prototype/content/ you would need to use - <img src="content/flag_usa.gif" width="84" height="63" alt="usa flag image" /> Edit: Alternatively, you can use a domain_root relative URL - <img src="/prototype/content/flag_usa.gif" />
  7. In edit_data.php, where is your code that is setting $id from the form field so that the query would match a row in your table?
  8. Form/form processing pseudo code - // form processing code if(form_submitted){ validate form data if(no form_errors){ // use form data } } // form code if(form_not_submitted OR form_errors){ if(form_errors){ display form errors } display form with existing field values (if present) } Example Form/form processing code - <?php // form processing code if($_SERVER['REQUEST_METHOD'] == "POST"){ //validate form data $form_errors = array(); // define array to hold form errors if($_POST['username'] == ''){ $form_errors[] = 'No username supplied!'; } if($_POST['password'] == ''){ $form_errors[] = 'No password supplied!'; } else { // further password validation if(strlen($_POST['password']) < 5){ $form_errors[] = "Password length must be at least 5 characters!"; } } if(empty($form_errors)){ // use form data echo "Thank you for submitting your data, " . htmlentities($_POST['username'],ENT_QUOTES) . ".<br />"; } } // form code if($_SERVER['REQUEST_METHOD'] != "POST" || !empty($form_errors)){ if(!empty($form_errors)){ //display form errors echo "Please correct the following form errors -<br />"; foreach($form_errors as $error){ echo "$error<br />"; } } //display form with existing field values (if present) ?> <form method='post' action=''> <label for="username">Username:</label> <input type='text' id='username' name='username' value='<?php echo isset($_POST['username']) ? htmlentities($_POST['username'],ENT_QUOTES) : ''?>'> <br /> <label for="password">Password:</label> <input type='password' id='password' name='password' value='<?php echo isset($_POST['password']) ? htmlentities($_POST['password'],ENT_QUOTES) : ''?>'> <br /> <input type='submit'> </form> <?php } ?>
  9. 0 * 604800 is zero and just about every (time() - filemtime($file) is going to be greater than zero.
  10. Do your numbers have commas in them or was the example in your first post just an example? A comma as a thousand's separator is a human-readable aid and computers treat the comma as a stop character. Posting an actual example of your data and the code you tried would be the quickest way of getting a solution.
  11. If you want all the results available on the page, but want to randomly access the values, you would generally store the results in an array - $query = "SELECT source, COUNT(*) as cnt FROM states GROUP BY source"; $result = mysql_query($query) or die(mysql_error()); $data = array(); while($row = mysql_fetch_array($result)) { $data[$row['source']] = $row['cnt']; } // display a specific value somewhere - echo $data['colorado'];
  12. echo "{$row['source']} is listed {$row['cnt']} times.<br />";
  13. Everything that we have been posting is based on the code in your first post. Perhaps if you showed your database table definition, some data, and what result you expect for that data, someone could directly help. Edit: And no, what you have shown as the expected result so far in the thread is not sufficient to help you.
  14. You would do exactly what the link that harristweed posted shows. If you use GROUP BY source, the query will consolidate all the rows for each state together. If you use SELECT source, COUNT(*) as cnt in the SELECT term, you can reference the state name using $row['source'] and you can reference the count for that state using $row['cnt'] @souper, don't put queries inside of loops. You can almost always use one query to get the data you want in the order and format that you want it.
  15. If I'm not mistaken, the join condition would need to be - ON b1.sid = b2.id
  16. ^^^ That's an extremely bad idea. You do realize that php, being a parsed, tokenized, and interpreted language, is about 100 times slower at scanning through and finding information in a database table then if you use the database engine to do this. You have missed the point of why databases exist. To let you efficiently - store, find, retrieve, and manipulate information. By storing serialized object values, all you can do is store/retrieve and since your scheme doesn't have the ability to find and retrieve specific row(s), you must then retrieve everything and scan through it using some slow parsed, tokenized, interpreted php code. You are also not looping through anything in your login function, so of course only the first one in the table works.
  17. NOT this again. The only way that a web based 'rating system' can be used reasonably well, is if there is only 'positive' voting. If you cast a vote at all, it can only contribute to increasing a value. Therefore, there is no way to arbitrarily or capriciously negatively affect the value.
  18. I hope that $_COOKIE['uid'] isn't just an auto-increment value from your database table, as that would allow anyone to simply try a series of sequential numbers and easily appear to be anyone, even you when they find your uid value. As to the stated login problem, it would take seeing enough of your code that duplicates the problem to determine what is causing it. Best guess is you have an error in your logic.
  19. Whatever is causing the code to not work, won't change by jumping to a different host. You must find and fix whatever is causing the problem. A) What do you get when you do a 'view source' of the blank page in your browser? B) You can normally use a LOCAL php.ini. Have you checked the host's FAQ section at all to find out if you can use a local php,ini (sometimes it is named differently.) C) Can you even put in a simple echo 'page requested'; statement at the start of your code, before any of the conditional statements and get the 'page requested' output? D) It would help if you posted all the relevant code. For example, suppose there is something wrong with your form and it doesn't submit anything on the live server or your database.php file is dieing with no output/error messages?
  20. The position of the rows in the table can be anything (for example if you deleted row(s), new rows will be inserted into the space previously used by the deleted row(s).) The database doesn't care where any row is at and neither should you or your code. If you want the rows retrieved in a specific order, use ORDER BY to achieve that ordering.
  21. So, do you happen to have a debugging add-on installed in your browser and if so, when you disabled it, did the problem still occur? If this is being triggered by double-requests from your browser, it could also be an indication that your page is doing something extremely inefficient and is taking a long time on the server to produce the page.
  22. If your DATE/DATETIME information happens to be stored in a database, most databases have a number of date/time functions, such as - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-add
  23. I'm going to guess that your browser is requesting the page twice (this usually happens due to a debugging add-in in your browser) and it occasionally occurs fast enough that the second request is being serviced before the first request has completed and released the session data file. You need a session_start() statement on any page the sets or references a $_SESSION variable.
  24. What's your overall goal and the desired output/result? Because programming is an exact science (computers only do exactly what their code and data tell them to do), when you don't take into account everything you are trying to accomplish (i.e. define what you are trying to achieve first before you write any code), you end up wasting time rewriting your code and redefining your data structures or you end up with an inefficient kludge of code that is hard to read, troubleshoot, and fix. The solution to: "how to get those 10 elements inside match_stats and how to grab the stat name= nickname from each element" can be completely different from: "I want to get the following fields for each team and display them like so _________ and/or insert them into a database like so _________ and/or calculate/sort them like so _________".
  25. You would use an xpath query. Assuming you have read that URL into a file doc.xml - <?php $xml = simplexml_load_file('doc.xml'); $result = $xml->xpath("//stat[@name='nickname']"); // Selects all the stat elements that have an attribute named 'name' with a value of 'nickname' foreach($result as $node){ echo "Nickname: $node<br />"; } ?>
×
×
  • 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.