Jump to content

Naez

Members
  • Posts

    99
  • Joined

  • Last visited

    Never

About Naez

  • Birthday 12/06/1987

Contact Methods

  • AIM
    naes+m+a+n+88

Profile Information

  • Gender
    Male
  • Location
    California

Naez's Achievements

Member

Member (2/5)

0

Reputation

  1. Okay so I've got a couple tables: articles ----------- id - primary cat_id - INT index foreign #links up with categories table author_id - INT index foreign # links up with user table title - varchar(255) body - longtext url - varchar(255) # [b]url-safe-article-title-for-seo-links[/b] ----------- categories ----------- id - primary category - varchar(255) ----------- The only thing is, I want to seperate things off by level too. So for instance: "Advanced" articles will carry say category id's 3,4,5 "Intermediate" will carry 2 "Novice" will carry cat_id 1 with room for expansion of course. Now I know a couple ways to do this... add a new table, or add a parent_id field in categories. But I'm not sure the best way to do this so hralp! And more importantly, how to generate a big-ass query that will do all the following: [b]Novice:[/b] - Novice Category 1 (2 articles) [b]Intermediate[/b] - Intermediate Category 1 (5 articles) - Intermediate Category 2 (2 articles) - Intermediate Category 3 (20 articles) [b]Advanced:[/b] - Advanced Category 1 (2 articles) # I know I'll need some semi-intricate joins and groupings, and a COUNT() I'm not exactly the SQL JOINs master so hopefully I can get some hralp. Also on side note should I use longtext or something else for the body? Thanks!
  2. Okay so I've got a couple tables: articles ----------- id - primary cat_id - INT index foreign #links up with categories table author_id - INT index foreign # links up with user table title - varchar(255) body - longtext url - varchar(255) # [b]url-safe-tutorial-title-for-seo-links[/b] ----------- categories ----------- id - primary category - varchar(255) ----------- The only thing is, I want to seperate things off by level too. So for instance: "Advanced" articles will carry say category id's 3,4,5 "Intermediate" will carry 2 "Novice" will carry cat_id 1 with room for expansion of course. Now I know a couple ways to do this... add a new table, or add a parent_id field in categories. But I'm not sure the best way to do this so hralp! And more importantly, how to generate a big-ass query that will do all the following: [b]Novice:[/b] - Novice Category 1 (2 articles) [b]Intermediate[/b] - Intermediate Category 1 (5 articles) - Intermediate Category 2 (2 articles) - Intermediate Category 3 (20 articles) [b]Advanced:[/b] - Advanced Category 1 (2 articles) # I know I'll need some semi-intricate joins and groupings, and a COUNT() I'm not exactly the SQL JOINs master so hopefully I can get some hralp. Also on side note should I use longtext or something else for the body? Thanks! EDIT - Double post - locked.
  3. I do not believe so. In my opinion you should create your database connection before invoking the function, then send the $db object to the function.
  4. Check out tutorials on DOMdocument
  5. Yep was just about to suggest a cron job.
  6. Just store a timestamp instead.
  7. Unfortunately you are wrong in this regard. When using a die statement in this way you must use suppression as I previously stated. Consider the following: w/o suppression <?php mysql_connect('fakehost','user','pass') or die('ERROR!: ' .mysql_error()); ?> Output: Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'fakehost' (11001) in C:\xampp\htdocs\index.php on line 3 Now with suppression: <?php @mysql_connect('fakehost','user','pass') or die('ERROR!: ' . mysql_error()); ?> Output: ERROR!: Unknown MySQL server host 'fakehost' (11001) Also, using @ does not "severely" increase execution time, I don't know where you got that idea. However I do agree that errors should be handled differently, but I wouldn't get into that on subject on this board (More people should use the exception class).
  8. Suppresses errors, and if you don't have it you usually won't see the die statement in most PHP installs (the script will still die regardless though).
  9. It defines a constant. Constants can only be scalar types. http://www.php.net/manual/en/language.constants.php
  10. Basically, its preventing you from accessing include pages directly. for instance: main.php <?php @define('IN_MAIN',true); include('test.php'); // code goes here ?> test.php <?php @defined('IN_MAIN') or die('Not in main'); ?> If test.php is accessed directly, defined('IN_MAIN') would return false so the parser would skip to the die statement... much like when you see: mysql_connect('','','') or die(mysql_error());
  11. <?php function textarea ($str) { $open = '<textarea>'; $close = '</textarea>'; // Count the opening tags preg_match_all ('/\[textarea\]/i', $str, $matches); $opentags = count($matches['0']); // Count the close tags preg_match_all ('/\[\/textarea\]/i', $str, $matches); $closetags = count($matches['0']); // reiterate through loop to close all the open tags, there's probably a more elegant way of doing this $unclosed = $opentags - $closetags; for ($i = 0; $i < $unclosed; $i++) { $str .= $close; } // Do replacement $str = str_replace ('[textarea]', $open, $str); $str = str_replace ('[/textarea]', $close, $str); return $str; } ?>
  12. Try: <?php $x = $_GET["suggestion"]; $filename = "data.txt"; $handle = fopen($filename, "ab"); fwrite($handle, $x); $contents = fread($handle, filesize($filename)); echo $contents; fclose($handle); ?> I used "ab" in the handle because I assume you want to "append" the suggestion to the rest of the contents?
  13. I have installed the following extensions: iconv.dll php_domxml.dll libxml2.dll Restart Apache, bada bing, I still get this error Fatal error: Call to undefined function domxml_open_mem() in C:\server\apache\htdocs\***\***.php on line 34 I'm really at a loss here.
  14. Naez

    PDO question

    is there a good way to do this with extending PDO or just go with a custom class to accomplish?
  15. Naez

    PDO question

    PDO is a built-in database abstraction class and it looks by the way things are heading it will be the standard for everything database related soon enough.
×
×
  • 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.