e_i_pi's Profile User Rating: *****

Reputation: 822 Master
Group:
Mentors
Active Posts:
1,750 (0.76 per day)
Joined:
30-January 09
Profile Views:
51,702
Last Active:
User is online 13 minutes ago
Currently:
Viewing Board Index

Previous Fields

Country:
AU
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
AMD
Favorite Gaming Platform:
Playstation
Your Car:
Mitsubishi
Dream Kudos:
75
Expert In:
Databases

Latest Visitors

Icon   e_i_pi has set their status

Posts I've Made

  1. In Topic: Fetching Multiple Rows from Table and Adding Them into Another Table

    Posted 13 May 2015

    Not to mention SQL injection. What happens when the customer name is changed to ',''),('',' in the HTML? Just because the field is hidden doesn't mean it can't be altered by someone in their browser.

    But as to your problem, on the postback, have you tried the following in your code?
    error_log(var_export($_POST, true));
    
    

    ...and then checking your error logs? You need to look at your $_POST array to see if the problem if with the data being posted back, or the way you are recursing through the data.
  2. In Topic: Why is there no boolean datatype in MySQL?

    Posted 13 May 2015

    MySQL has an aliased datatype BOOL (or BOOLEAN), which maps to TINYINT(1). I would recommend sticking with TINYINT(1), given that is the way a boolean value is traditionally stored in MySQL.
  3. In Topic: [Question] Getting 5 Most Recent Forum Posts on Home Page

    Posted 12 May 2015

    Sorry to come late to the party again. A search of the term "phpbb initialize db object" on Google reveals this phpBB wiki page on using the DBAL (database abstraction layer).

    You can avoid all this pain though, there is another way. I'm generally against using the phpBB framework to poll the phpBB database, simply because the framework is a frankenstein of a codebase - object oriented, mixed with procedural, mixed with functional. It's a nightmare to deal with in all honesty.

    Looking at that code you posted above (where you had the non-object $db issue):
    $posts_ary = array(
    	'SELECT' => 'p.*, t.*',
    
    	'FROM' => array(
    		POSTS_TABLE => 'p',
    	),
    
    	'LEFT_JOIN' => array(
    		array(
    			'FROM' => array(TOPICS_TABLE => 't'),
    			'ON' => 't.topic_first_post_id = p.post_id'
    		)
    	),
    
    	'WHERE' => str_replace( array('WHERE ', 'forum_id'), array('', 't.forum_id'), $forum_id_where) . '
    					AND t.topic_status <> ' . ITEM_MOVED . '
    					AND t.topic_approved = 1',
    
    	'ORDER_BY' => 'p.post_id DESC',
    );
    
    


    ...well, that steaming pile of code can be rewritten as a SQL query that doesn't even need to go through the phpBB DBAL:
    SELECT 
    	p.*,
    	t.*
    FROM phpbb_posts p
    LEFT OUTER JOIN phpbb_topics t
    	ON t.topic_first_post_id = p.post_id
    WHERE t.topic_status <> 2
    AND t.topic_approved = 1
    ORDER BY p.post_id DESC
    
    

    This will get all the columns from both the phpbb_posts and phpbb_topics tables, though you might not need all the columns. I would suggest looking in your database tables to see what columns you need, and just retrieve those columns. This SQL query can be run through your own DBA (database accessor) code, which you most likely already have. If not, you'll have to set that up, there are many tutorials around, if you start a new post in this forum I'm sure the community will be happy to help.

    You may notice in the DBAL code, these lines:
    'WHERE' => str_replace( array('WHERE ', 'forum_id'), array('', 't.forum_id'), $forum_id_where) . '
    AND t.topic_status <> ' . ITEM_MOVED . '
    
    

    ...and that I have changed them to this:
    WHERE t.topic_status <> 2
    
    

    The reason for this...
    The first line of the DBAL code simply filters by the selected forums. In your case, you want all forums, so I've removed that line. The second line of the DBAL refers to ITEM_MOVED, which is a defined constant in phpBB. It's value is 2, and is found in the file \includes\constants.php.
  4. In Topic: undefined index error

    Posted 8 May 2015

    Errors generally show line numbers so you can easily find them. Maybe try checking line 75
  5. In Topic: [Question] Getting 5 Most Recent Forum Posts on Home Page

    Posted 8 May 2015

    View PostTyr4el, on 09 May 2015 - 05:27 AM, said:

    Thanks for your help! What do the => and -> symbols mean? I thought they were just ways to draw arrows without having an arrow symbol in text lol. Do I need to replace any code in there?

    => is assignment of a value to an array key
    -> is the calling of a method on an object

    Quote

    And just out of curiosity, why are we replacing that part in the while block? What does it do otherwise? I see the example that's linked on that page too and it looks exactly like I want but where do I put something like a div element in that PHP code? I want to wrap it in a div so I can easily style it in CSS later.

    That part of the while block is building an object. You don't want to build an object necessarily, you want to output HTML (I say necessarily, because you can get an object to output HTML, but only if that's the way the object is built in code).

    You can wrap it in a div element, that's fine, however you want to build your HTML output.

My Information

Member Title:
= -1
Age:
40 years old
Birthday:
June 24, 1974
Gender:
Location:
Australia
Years Programming:
4
Programming Languages:
HTML, XML, jQuery, PHP, SQL, MySQL, VBA, VBScript, PostgreSQL

Contact Information

E-mail:
Private
Website URL:
Website URL  http://www.artofwar.cc/

Comments

Page 1 of 1
  1. Photo

    cupidvogel Icon

    09 Jun 2012 - 11:30
    Ha ha, I really liked your "if(navigator.appName == 'Microsoft Internet Explorer')" theme!
  2. Photo

    Duckington Icon

    04 Apr 2012 - 00:57
    It's not live yet, still developing and then going into beta test. I haven't actually decided on a name yet, so no domain for it.
  3. Photo

    modi123_1 Icon

    13 Mar 2012 - 06:56
    Ha.. well good luck with it.. it's always a good butt of a joke.
  4. Photo

    RudiVisser Icon

    08 Mar 2012 - 15:20
    You know, I only just worked out what your avatar is. Love it!
  5. Photo

    RudiVisser Icon

    06 Sep 2011 - 00:37
    Thank you very much :-D
  6. Photo

    RudiVisser Icon

    06 Sep 2011 - 00:37
    Thank you very much :-D
  7. Photo

    e_i_pi Icon

    05 Sep 2011 - 22:15
    Ah thank you :) I'm a fan of minimalism, so I wwanted something nice and simple, plus you just can't go past red and black!
  8. Photo

    no2pencil Icon

    05 Sep 2011 - 19:52
    Love your avatar!
  9. Photo

    Sayid Ahmed Icon

    13 Jul 2011 - 14:02
    thanks for the add.
  10. Photo

    Dormilich Icon

    17 Feb 2011 - 13:25
    just wanted to congratulate for the funny thread title "OOP, PDOs, pain, tears".
Page 1 of 1