0

I wrote some code as a start for a username and password registration page but i cant get the first bit to work. The page with the forms corresponding to the variables at the top work fine but when redirected to this page it just gives a blank white page.

I seem to get this error every time i write some code that is not just basic echo or something like that... Can someone tell me what is wrong with the code and is there any good php editor where you can see error messages or somethilng like that?

This is not the first time i get the same blank page error and i would love to know what i'm doing wrong.

<?php
$user = $_POST["username"];
$pass = $_POST["password"];
$conf_pass = $_POST["conf_password"];

$con = mysql_connect("localhost", "webuser1", "12345");
if (!$con) {
  die('Could not connect: ' . mysql_error());
}

if($pass != $conf_pass) {
  echo ("passwords don't match, <a href="./reg_form.php">return</a>");
}



mysql_close($con);

?>
7
  • 1
    error_reporting can be your friend. Commented Mar 8, 2012 at 8:23
  • @ghbarratt giving a link to the manual is nice when you suggest a function. php.net/manual/en/function.error-reporting.php Commented Mar 8, 2012 at 8:24
  • "Php white page". Not a suitable question title! Commented Mar 8, 2012 at 8:26
  • Perhaps a better title would be "PHP failing to show error messages" or something along those lines Commented Mar 8, 2012 at 8:26
  • In your above code, if the mysql connection is successful and the passwords do match, I would expect a white page. Because if those conditions are satisfied, you are not outputting anything {Edit, unless the above code fragment is only a part of the page] Commented Mar 8, 2012 at 8:28

5 Answers 5

2

A blank white page often indicates a 500 Internet Server Error, which usually means you have a syntax or other error in your code.

In your case the error is in the quotes, try changing to:

 echo ("passwords don't match, <a href='./reg_form.php'>return</a>");

I suggest turning on error reporting in your code, or you can check your error log, this will tell you what the problem is and the line number.

error_reporting(E_ALL);
ini_set('display_errors', '1');

Also, if using Firebug, you can see the 500 Internal Server Error on the Net tab.

Sign up to request clarification or add additional context in comments.

1 Comment

it seems the error was in the quotes, i feel a little stupid now. thank you anyway
1

You can set the errors to show using:

ini_set("display_errors", 1);

Comments

0

There are errors occurring on your code. To see what error is being generated. Use this command on the top of your page.

error_reporting(E_ALL);

Comments

0

Get an editor with syntax highlighting and errors like this will stand out. Some like Zend Studio also check for syntax errors.

Comments

0
echo ("passwords don't match, <a href="./reg_form.php">return</a>");

creates the following error:

Parse error: syntax error, unexpected '/' in ...

Try changing that line to:

echo 'passwords don\'t match, <a href="/reg_form.php">return</a>';

error_reporting could have revealed this to you (as I suggested in the first comment).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.