Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. @belmon, the error message you were getting, but which you did not post entirely, stated where the output was occurring at. Had you posted it or read that part of it, you would have directly known that the output was occurring in your db.php file. Just because you have php code that 'works' on one server, does not mean that it will work on all server configurations. Php has a few got ya's that hide problems in your code, so if you get errors when moving code between servers, you have to consider that the code really does have a problem in it that needs to be fixed. In most of these cases, once you correct the problem that is causing the error message, that portion of the code will work on all server configurations.
  2. So, you want to match rows where any portion of the username is like $idea or any portion of the fname is like $idea or any portion of the lname is like $idea or any portion of the tags is like $idea? SELECT * FROM users WHERE username LIKE '%$idea%' OR fname LIKE '%$idea%' OR lname LIKE '%$idea%' OR tags LIKE '%$idea%'
  3. username AND fname AND lname AND tags ^^^ The above is logically AND'ing the contents of each of those columns together, which most likely is a TRUE value (unless you have FALSE and/or NULL values), then trying to see if TRUE LIKE '$idea' What exactly are you trying to accomplish?
  4. For the year start/end - SELECT COUNT(*) FROM news WHERE `show`='true' AND IF(CURDATE() >= CONCAT(YEAR(CURDATE()),'-07-01'), date BETWEEN CONCAT(YEAR(CURDATE()),'-07-01') AND CONCAT(YEAR(CURDATE())+1,'-06-30'), date BETWEEN CONCAT(YEAR(CURDATE())-1,'-07-01') AND CONCAT(YEAR(CURDATE()),'-06-30'))
  5. I'm assuming that the css in question is in - stylePHP.php? Rename that to stylePHP.css and change the link/href= to match.
  6. I recommend that you do a 'view source' in your browser and post the actual HTML output.
  7. SELECT page FROM keywords WHERE keyword_id IN(17,36) GROUP BY page ORDER BY SUM(weight) DESC You would only use a UNION when you have more than one table.
  8. Php programmers hate short open tags because they result in php code that is not portable between different servers. You should only use short open tags in code that will be used on a server that you own so that you can insure that the setting will always be turned on or you can simply realize that you will spend several orders of magnitude more time troubleshooting problems in code that contains short open tags, then the few seconds you saved in typing time, and never use them, ever.
  9. Taken out of context, the posted code does not produce a php syntax error. You must have something prior to that point in the code or you have a corrupted source file and the copy/paste into the forum post only copied the actual ASCII visible characters.
  10. $_SERVER['DOCUMENT_ROOT'] will give you the file system path to the current document root folder. You can then concatenate a path onto the end of that to get an absolute file system path.
  11. You MUST test for errors before you can access ANY of the uploaded file information. See Example #3 at the following link for how you can iterate over any number of multiple uploaded files - http://is.php.net/manual/en/features.file-upload.post-method.php You would put your code that accesses the uploaded file information inside the if ($error == UPLOAD_ERR_OK) { code to access the successful uploaded file information } statement. Also, when validating user supplied information, you should tell the user in the error message that you output exactly what was wrong with the data he supplied. You should echo the $FileType value as part of your error message so that you have debugging information during testing (different browsers and browser versions supply different type values for the same file) and a user has more information about what he actually submitted that was incorrect.
  12. Add the following line of code right before you call echocsv( $row ); - $row['products_image'] = 'http://www.domainname.com/images/' . $row['products_image'];
  13. That error is a generic - There is some sql syntax (or lack of) in your sql statement that is out of place. There is no one single solution you can search for to solve it because you must examine the actual sql statement to find what is wrong with it. However, the part of the error message - the right syntax to use near '', generally means that a numerical value was missing. You need to form the actual sql statement in a php variable (if it is not already) and echo that variable as part of your error reporting logic (the code that is displaying the current mysql error.)
  14. To loop over a date range (valid from 1970 or 1901, depending on php version and op system, to 2038) - <?php $date = '2011-07-01'; // starting date (YYYY-MM-DD) $end = '2011-07-31'; // ending date (YYYY-MM-DD) while($date <= $end){ // your code using the $date echo $date . '<br />'; $date = date('Y-m-d',strtotime("$date +1 day")); // get the next date } ?>
  15. Yes, any time you find yourself repeating blocks of code that only differ in the value being used, you would make an array of the values, iterate over the array, and produce the output you want. For the case of a select menu, where you want to select one (or more) of the options based on a value(s), you would simply test as you are iterating over the array of choices and output the selected='selected' when the current value matches a variable.
  16. The order in which you validate the fields should be in the order that you want the error message(s) to be output, which should probably be in the same order as the fields so that the visitor is presented with errors that have some correlation to the layout of the form fields. If someone just entered - product name, price, image, city, state, zipcode, and country, they would want to see any error messages in that same order, or even better, display each validation error next to the corresponding field. Using an array to hold the errors and using an array index name that corresponds to the form field, will make displaying the validation error next to the form field easier because you can simply test if the array index name is set and output the error message at the point where you output the form field.
  17. ^^^ Form fields will be submitted and exist (except for radio and checkboxes), even if they are empty. Your logic testing if(!$some_field) won't fail if a variable by that name exists at all. Your validation logic should do a few things different - 1) Use an array to both hold the error messages and to flag if there were any validation errors (i.e. if the array is empty at the end of your validation, there were no errors.) 2) You should validate all the form fields (your else if logic will stop validating on the first problem.) 3) You should specifically test if the variables are empty strings or not (you can use empty, except if there could be a valid number zero as data since a zero is considered to be an empty value.) 4) I'm guessing you removed code when you posted it, but your code should test if the current visitor is authorized to submit data and have it inserted into the database, that a form was submitted before doing anything on the page, and it needs a session_start() statement and a database connection. Edit: 5) The uploaded file information will be in $_FILES['file'], not $_POST['file'].
  18. ^^^ Do you have a form field named 'role', so that if(){} statement will be true?
  19. Your code has error messages for the user (your $error = "..."; statements), but you need to also (always) have application error handling, where you display/log the actual information about errors that occur when your code runs. If you use a trigger_error; statement in addition to your $error = "..."; statements, you can get php to automatically display and/or log information about the problem. Use something like - trigger_error("Query failed: $sql, Reason: " . mysqli_error($link)); If you set error_reporting to E_ALL (it should always be set to this value or to a -1) and set display_errors to ON for your development system, the trigger_error statement will display the information you pass it along with the filename and line number (of the trigger_error statement) where the error is occurring at. On a live site, you would have display_errors set to OFF and log_errors set to ON, so that the application error information will be logged but not displayed. Once you do this, you should be getting an sql syntax error at the group column name in the query because group is a reserved mysql keyword. You need to either rename your column to something else or you will need to enclose it in back-ticks `` every time you use it in a query. There may be other errors in the query, which is why you should always have application level error reporting/logging logic in your code.
  20. You need to start by making sure that your html/css is valid and error free. See the following two links - http://validator.w3.org/ http://jigsaw.w3.org/css-validator/
  21. It all depends on what it is you are tying to accomplish. If you have a form where you need to allow the visitor to choose between different operations for the data that was entered, then yes, there's nothing wrong with having more than one submit button in a form.
  22. You are getting a fatal php runtime error because of the $ on the mysql_query() function call. $result = $mysql_query("SELECT id FROM user WHERE oid = '$oid'"); If you were developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON, you would not need anyone to point out problems in your code like this one, because php would call your attention to the line with the error in it.
  23. How about using the same name="submit" for all of them, but using a different value="..." to indicate which one was submitted?
  24. I would just make the search term exactly what you are looking for - $surname = ucfirst($surname) .'|'. strtoupper($surname); $pattern="/\b($surname)\b/s"; For your example, $pattern would be: /\b(Law|LAW)\b/s
  25. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=338836.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.