Receiving a warning "A title can contain no more than one title, a new line is found"

I am doing coding in oops to upload an image in PHP. But after sending the image, it gives a warning

"The title can contain no more than one title, a new line is found"

Below is my function, in which its error message

public function ft_redirect($query = '') { if (REQUEST_URI) { $_SERVER['REQUEST_URI'] = REQUEST_URI; } $protocol = 'http://'; if (HTTPS) { $protocol = 'https://'; } if (isset($_SERVER['REQUEST_URI'])) { if (stristr($_SERVER["REQUEST_URI"], "?")) { $requesturi = substr($_SERVER["REQUEST_URI"], 0, strpos($_SERVER["REQUEST_URI"], "?")); $location = "Location: {$protocol}{$_SERVER["HTTP_HOST"]}{$requesturi}"; } else { $requesturi = $_SERVER["REQUEST_URI"]; $location = "Location: {$protocol}{$_SERVER["HTTP_HOST"]}{$requesturi}"; } } else { $location = "Location: {$protocol}{$_SERVER["HTTP_HOST"]}{$_SERVER['PHP_SELF']}"; } if (!empty($query)) { $location .= "?{$query}"; } header($location); exit; } 
+10
source share
6 answers

You must not specify more than two lines in the URL. Check URL.

 Good URL - "http://mail.google.com" - 1 line Bad URL - "http://mail. - 2 lines google.com/" 
+23
source

The problem may be in your phpMyAdmin, wp_options table, option_value.

If there is a space before the URL , it will generate an ERROR: warning: the title cannot contain more than one title, a new line is found in ...

+2
source

It seems that the variables you use to create the Location attribute have a new line character in them. Pass them through urlencode ()

0
source

Try encoding the url and it should work: http://php.net/manual/en/function.urlencode.php

0
source

You should put the URL http://example.com , please avoid http://example.com/ "" / "does not give the URL mismatch, so avoid, the same problem will come up in Wordpress. So try using like this.

0
source

This warning appears to indicate that you may have a new line [/ n] in the string contents of your variables. Example

  header("Location: ../control.php?post='$title1'&sample='$val'"); 

there are 2 variables here

$ title1 as well as & amp; $ Val

therefore, during operation, if this warning appears, a warning

"The title cannot contain more than one title, a new line is found"

Solution To remove the demolished new string contents of a variable Like this

  $val=str_replace(PHP_EOL, '', $val); $title1=str_replace(PHP_EOL, '', $title1); 

Then you can include the variables in the header


The perfect way to solve the problem is like this

 $url="../control.php?post='$title1'&sample='$val'"; $url=str_replace(PHP_EOL, '', $url); header("Location: $url"); 

** This will work 100%; **

0
source

Source: https://habr.com/ru/post/944054/


All Articles