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 (2/5)
0
Reputation
-
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!
-
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.
-
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.
-
Check out tutorials on DOMdocument
-
Yep was just about to suggest a cron job.
-
Just store a timestamp instead.
-
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).
-
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).
-
It defines a constant. Constants can only be scalar types. http://www.php.net/manual/en/language.constants.php
-
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());
-
<?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; } ?>
-
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?
-
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.
-
is there a good way to do this with extending PDO or just go with a custom class to accomplish?
-
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.