Reputation: 822 Master
- Active Posts:
- 1,750 (0.76 per day)
- 30-January 09
- Profile Views:
- Last Active:
- 13 minutes ago
- Viewing Board Index
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Favorite Gaming Platform:
- Your Car:
- Dream Kudos:
- Expert In:
Posts I've Made
Posted 13 May 2015Not 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?
...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.
Posted 13 May 2015MySQL 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.
Posted 12 May 2015Sorry 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.
Posted 8 May 2015Errors generally show line numbers so you can easily find them. Maybe try checking line 75
Posted 8 May 2015Thanks 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
QuoteAnd 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.
- Member Title:
- = -1
- 40 years old
- June 24, 1974
- Years Programming:
- Programming Languages:
- HTML, XML, jQuery, PHP, SQL, MySQL, VBA, VBScript, PostgreSQL
- Website URL: