Problem with short script

Hi there,
I get an output I can’t explain.

if (!isset($_SESSION)) {
include "mysqlopen.php";
        $uname = $_REQUEST['uname'];
        $pwd = $_REQUEST['pwd'];
if ($uname="" or $pwd=""){
echo "so far...";

gives me the output:
?> so far…
Since it is pure PHP, I can’t see where ?> is coming from.
any help welcome

Do you have a spurious ?> in mysqlopen.php by any chance?

What is the return statement supposed to do?

Right. Think further than one script when include.
Thank you very much.
The return goes back to the login page. I hope. Just read the manual.I have not a strategy for false inputs yet.
In fact I want to keep the previous inputs of the user; it’s irritating being forced to write all over again.

I don’t think return is going to work there - it’s not a function.

So long as you’ve not output anything to the browser, you should be able to use header to redirect back to the login page.

I wrote a function for that now, thanks. Wanted to avoid lol
In the PHP manual it says: Returns to the calling script. It doesn’t.

Try adding this declaration and two debug settings at the start of your PHP script. Remove when online.

declare(strict_types=1); // applies to this file only
error_reporting(-1); // applies to this and included files
ini_set('display_errors','1'); // applies to this and included files

Actually you can return from a script as well. You can even return a value to the script that includes it:


$a = require 'b.php';

echo $a;


return 'Hello world';

When you run a.php, it will echo Hello world.

Not saying it’s a good idea, just saying it’s possible :wink:


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.