Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7069209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:25:04+00:00 2026-05-28T05:25:04+00:00

My database tables 1 row looks like that I’m storing all variables that used

  • 0

My database tables 1 row looks like that

enter image description here

I’m storing all variables that used in body, in another column named vars. Then fetching all vars. If they are multiple, exploding by “,” symbol.

What I want to do is, fetch all used vars from db, then filter them by second function filter. As you see, filter has, 3 inputs: $content, $needle, $replacement .

$content – messages body,

$needle – %.what we are searching for.%

$replacement – is var that we got from database, defined by php. For ex, if I get wsurl from database, It’s already defined in my settings.php like DEFINE(“wsurl”, “www.yourdomain.com”).

Question is, how can I send defined value as third input – $replacement?

public function genMsg($id) {
    $msgid = $id;
    $stmt = $db->prepare('SELECT `body`, `status`, `vars` FROM `messages` WHERE `id`=?') or die(htmlspecialchars($this->db->error));
    $stmt->bind_param("i", $msgid) or die(htmlspecialchars($stmt->error));
    $stmt->execute() or die(htmlspecialchars($stmt->error));
    $stmt->bind_result($message, $status, $vars) or die($stmt->error);
    $stmt->fetch() or die($stmt->error);
    $stmt->close();
    $image = ($status == -1) ? "fail" : "success";
    if (isset($vars) && !empty($vars)) {
        if (strpos($vars, ",")) {
            $vars = explode(",", $vars);
            foreach ($vars as $key => $var) {
                $this->filter($message, $var, <HERE MUST BE DEFINED VALUE>);
            }
        } else {
            $var = trim($vars);
            $this->filter($message, $var, <HERE MUST BE DEFINED VALUE>);
        }
    }
    $data = array(
        'status' => $status,
        'message' => $message
    );
}

protected function filter($content, $needle, $replacement) {
    return str_replace("%'.$needle.'%", $replacement, $content);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:25:05+00:00Added an answer on May 28, 2026 at 5:25 am

    If I got your question right.
    This should help.

    <?php
        define('TEST', 'abc');
        echo constant('TEST');
    

    http://www.php.net/manual/en/function.constant.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 database tables that looks like this Subscriptions table member_id active 5
I've got a database that looks like this: ID Name ParentID 1 1 0
I have a table (Oracle database) that looks like: CREATE TABLE example ( idEx
I have a database with 2 tables. One of the tables holds a row
I want to insert a row into the Database using SqlDataAdapter. I've 2 tables
I want to create a new row in my database on a table that
I have 3 database tables, all of them have the same 5 columns. They
I have a database in which all of the tables have been generated by
We have a pile of old databases in archives that have a column named
Alright, so let's say I have a database with a table named COMPANY_PARAMETERS that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.