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 7726165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:08:46+00:00 2026-06-01T05:08:46+00:00

I am having the error Fatal error: Only variables can be passed by reference

  • 0

I am having the error “Fatal error: Only variables can be passed by reference” in the following lines of code.

$ag = array(M($forge[2][$i], NULL, TRUE), M($about[0]["text"], "Less", TRUE), M($address[0]["text"], NULL, TRUE), M($phone[0]["text"], NULL, TRUE), M($website[0]["text"], "...", TRUE));

if(CAT)
    array_push($ag, M($cat[1], NULL, TRUE));

$pf_args =  str_replace("%s, ", "", PLACEHOLDER, 4 - count($_POST['ad']));

file_put_contents("files/" . FILENAME . ".sql", vsprintf($pf_args, $ag), FILE_APPEND); 

The message shows error in the last line. Can any one suggest me the reason?

(Edit): M() is defined as:

function M($text, $str = NULL, $escape = FALSE) {
    if (!empty($str))
        $text = str_replace($str, "", $text);
    $text = str_replace("(Edit)", "", $text);
    $text = str_replace("More", "", $text);
    $text = str_replace("Less", "", $text);
    $text = str_replace("<br>", "\n", $text);
    if ($escape)
        return mysql_escape_string(trimText(html_entity_decode(strip_tags($text))));
    else
        return trimText(html_entity_decode(strip_tags($text)));
}
  • 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-06-01T05:08:47+00:00Added an answer on June 1, 2026 at 5:08 am

    The problem is this line:

    $pf_args =  str_replace("%s, ", "", PLACEHOLDER, 4 - count($_POST['ad']));
    

    The last argument is just for outputting the number of replacements. You have to pass a variable here, not the expression 4 - count($_POST['ad']). Just remove the last argument and it will work.

    mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )

    http://php.net/manual/en/function.str-replace.php

    If you want to limit the number of replacements, there are implementations of str_replace_once in the comments of str_replace‘s manual page.

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

Sidebar

Related Questions

I'm having following Zend Session error with my zend project: Fatal error: Uncaught exception
here is the part if having error. Fatal error: Using $this when not in
I'm having trouble with this PHP script where I get the error Fatal error
I`m having the following error . Why am I having this error and how
I'm currently having following error message when executing a .sql file with about 26MB
I'm having an error I can't seem to get past. I have a simple
I am having a strange error that seems to occur only in Samsung Galaxy
So, I'm having this weird error: Catchable fatal error: Object of class Template_Standard could
Using log4j to log specific events (DEBUG, ERROR, FATAL..) having specified in the properties
I am having really weird problem: Fatal error: Allowed memory size of 134217728 bytes

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.