Jump to content

willfitch

Members
  • Posts

    109
  • Joined

  • Last visited

    Never

Everything posted by willfitch

  1. I hope I understand what you're talking about. Try this: <div id="php_code_header">PHP Code Example:</div> <div id="php_code"> <?php highlight_string($code_to_highlight); ?> </div>
  2. 1. highlight a file = highlight_file('file.ext'); 2. highlight a string = highlight_string($string);
  3. It could. $_REQUEST works the same way as register_globals.  Remember the letters GPCS.  1. GET 2. POST 3. COOKIE 4. SESSION That is the order PHP will look for that variable.  Post some of the code you use to handle the form.
  4. My first guess would to first ensure that the description hidden field is within the <form> </form> tags.  If it is, try using $_POST['description'] rather than REQUEST.  It's safer.
  5. It looks like your problem isn't saving 20 questions into the database.  Your problem looks like you don't know how to setup a form, catch the POSTed data, and then insert into the database.  Your question is way to generic and you have shown us a form, that looks like it has nothing to do with 20 questions. So I'm going to ask this question:  what is the problem?
  6. There are a couple of ways to do this: Using SQL SELECT FORMAT(field_name) or PHP: number_format($int)
  7. $_COOKIE['cookie_name']
  8. That is two threads.  Also, you need to use apachefreaks.com for these questions.  This is a PHP installation forum category.
  9. Actually, You can run into issues with short tags (<? ).  If you are trying to use XML with PHP, XML will require the opener (<?xml), and allowing short tags will confuse the interpreter.
  10. Well, If you are hard-coding your parameters with your if conditions, you could use file() and do a foreach() loop and loop through each line.  Once you hit the strawberry, insert your new line. [code=php:0] <?php $file = file('file.txt'); foreach($file as $line_number => $content) {     if (trim($content) == 'strawberry') {         // do your thing here.     } } ?> [/code]
  11. The error PHP is giving you is what it says it is.  You are trying to call members of a class on an item that's not an object.  In this case $core->user->function(), user is not an object, so you can't call methods and properties on that.  This is known as dereferencing, not to be confused by C and C++ dereferencing which is accessing a pointer, which accesses an address in memory.  Here is an example of what you are looking for: [code=php:0] <?php // First class we create is accessed from within the UserManagement class class UserSettings {       public $password;       public function changePassword($pass) {             $this->password = $pass;       } } // Parent class class UserManagement {       public $user;       public function __construct() {             $this->user = new UserSettings();       } } $core = new UserManagement(); $core->user->changePassword('newpassword'); ?> [/code] You see, dereferencing allows properties, and even methods to have their own set of properties and methods, eliminating the need to instantiate tons of different classes.  BE AWARE that creating many classes to be accessed by a parent class will affect performance.  Does this clear things up?
  12. Why are you using fopen AND file_get_contents?  Also, it sounds more like you are needing file() to place into an array and loop through the content.
  13. It really depends on your access to modifying configurations.  If you have access to the httpd.conf or have AllowOveride set to All in your shared hosting configuration, mod_rewrite is the easiest, and typically safest solution.  Why do I say safest? Simply put, as a developer, it's easy to make mistakes.  You will have to code overhead to parse the URL and get the strings needed to present data/content to the browser.  Also, if you aren't careful, you could be a good candidate for SQL injections.  What's the biggest reason to use mod_rewrite?  IT'S ALREADY WRITTEN!  Reuse the capabilities that are at hand, rather than coding everything from the hip.  Mod_rewrite is very efficient, and can do way more than you probably know.  Give it a shot!
  14. Hello emehrkay, I'm not sure I understand your question, and it is always better to put code examples of your issue, but I'll try to address what you might be talking about: You mentioned something about a tab and carriage return.  Use trim() to strip whitespace (or other characters) from the beginning and end of a string. As for the clearing the ob issue, I think you should reference ob_clean().
  15. Assuming the checkboxes are sent as an array, you could use ksort(), sort(), asort() and a variety of other array sorters.  Try this URL http://us2.php.net/sort
  16. Hey neylitalo, As far as I know, you can't stop passing by reference in PHP5.  However, if you are trying to make copies of an object, simply use the "clone" keyword. Example: [code=php:0] <?php $obj1 = new Class(); $obj2 = clone $obj1; ?> [/code] This should help your issue.
  17. Have you tried testing this in you loop? [code=php:0] <?php $i=0; while ($row = $result->fetch_object()) {     if ($i == 3) { // 4         $content .= '<tr>';         $i = 0;     } } [/code]
  18. In PHP4, they aren't passed by reference unless you append the ampersand (&) to that particular class (i.e. $var = &new Class()).   In PHP5, the default is to pass by reference.  Also, it depends on the returned value of the method, and whether or not you have cloned that object
  19. Hey Rony, It appears you may be going at this a little too weird.  You are actually putting the array values inside the URL?  Why don't you build a comma seperated list, and assign them to a get variable?  Can you please explain what the recieving file looks like as well?
  20. PHP.ini max_execution_time=0 This will allow unlimited execution time.  If you have permissions, you can also add set_time_limit(0) to allow unlimited time.
  21. It would be redarrow, but I think he's having issues more on his SELECT statement.  Take a look at that structure.
  22. Your data structure is very confusing.  It's even more confusing since you didn't provide any details on it.  Lastly, this is phpfreaks.com, rather than mysqlfreaks.com.  With that, maybe this is what you are looking for: SELECT pa_categories.category_name AS category_name1,/* parent category */ pa_categories.cateogry_name AS category_name2 /* subcategory */ FROM pa_categories LEFT JOIN pa_subcategory_category_map ON pa_categories.category_id=pa_subcategory_category_name.subcategory_id
  23. Like I said, it's as reliable as the browser sending the headers.  When I wrote a C++ crawler, I sent a user agent header that corresponded with my crawler.  It is very easy to spoof, but under what circumstances are you testing this other than javascript?  Sometimes it can actually be better to detect within JavaScript, since JS would have been already downloaded.  Even better, detect with both!
  24. That's odd. Using the test script: [code=php:0] <?php $username = 'Will'; $string = 'Please help {name}.'; $string = str_replace("{name}",$username,$string); echo $string; ?> [/code] Works fine for me.  It sounds like there is either an issue with the POSTed values, incorrect comparison (i.e. mistakenly entering {name} rather than {username}, or the rows being pulled back.  Do a var_dump($_POST['message']) and tell me what it says.
×
×
  • 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.