You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
-
Go check global variables provided from WordPress such as $wpdb. Why you define $db when you already have $wpdb ? Also $db->tb_posts should be $wpdb->posts same for the meta. If you insist on using your own keep in mind that you must whitelist and escape table names manually before inserting them into your query. You will be flaged for stuff like that if you dont follow the guidelines.Snuffy– Snuffy2025-09-29 07:54:56 +00:00Commented Sep 29, 2025 at 7:54
-
@Snuffy can you guide me which type of escape I required here?Kaushal Patel– Kaushal Patel2025-09-29 08:21:04 +00:00Commented Sep 29, 2025 at 8:21
-
If you provide some code to look up. WIth this its unclear what you define how and so on.Snuffy– Snuffy2025-09-29 08:47:08 +00:00Commented Sep 29, 2025 at 8:47
-
@Snuffy $sql_orders = $wpdb->prepare( "SELECT p.* FROM {$db->tb_posts} p INNER JOIN {$db->tb_postmeta} pm ON p.ID = pm.post_id AND meta_key = %s AND (meta_value = %d OR meta_value like '%s')", '_user_id',$user_id,$user_id_str); $sql = $sql_orders . $sql_rest; $order_posts = $db->wpdb->get_results($sql); # You cannot add variables like "$db->tb_posts" directly to the SQL query. # Using wpdb::prepare($query, $args) you will need to include placeholders for each variable within the query and include the variables in the second parameter.Kaushal Patel– Kaushal Patel2025-09-29 08:58:41 +00:00Commented Sep 29, 2025 at 8:58
-
Please edit your question and add the code. Dont post in comments.Snuffy– Snuffy2025-09-29 09:25:23 +00:00Commented Sep 29, 2025 at 9:25
|
Show 6 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. python-3.x), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-php