Page 1 of 2

Need professional help!

Posted: Thu Mar 23, 2006 2:45 pm
by Cheeseboy
Hi, I have had this problem for many days on here: http://www.codingforums.com/showthread.php?t=82504 Now i need professional help so i came here. :D

Thx

Posted: Thu Mar 23, 2006 2:57 pm
by matthijs
Did you set

Code: Select all

ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);
at the top of the script to spot any errors and also var_dump($var) everywere in between, so you can see what's happening?

Posted: Thu Mar 23, 2006 3:17 pm
by Cheeseboy
nope it didnt show anyerrors is it ok to get rid of all the html tags? since tis a .php file?

Posted: Thu Mar 23, 2006 3:44 pm
by matthijs
Which html tags?

As long as you seperate the html and php itis ok

Code: Select all

<?php
// this is php
$var = 'this';
?>
<h2>Normal html</h2>
About you script: what you can do to debug it is after each line of code var_dump the variables to see if they are empty or what they contain. That'll lead you to the source of the trouble fast.

Code: Select all

<?php
$name = $_POST['name'];
var_dump($name);

// etc
?>

Posted: Thu Mar 23, 2006 4:03 pm
by RobertGonzalez
Your code should be throwing a header error at the very least since you are calling session_start() after you have outputted html to the browser. Try doing somthing like this and see what the source of the output is.

Code: Select all

<?php
session_start();
?>
<html>
<head>
<title>validate.php</title>
</head>
<body>
Ok, we are about to start: <?php echo date("m-d-Y g:i A"); ?>.
<?php
if (isset($_POST))
{
	$user_name = $_POST['user_name'];
	$password = $_POST['password'];
	$db_user = 'mysql_username';
	$db_pass = 'mysql_password';

	//connect to the DB and select the "dictator" database
	$connection = mysql_connect('localhost', $db_user, $db_pass) or die(mysql_error());
	mysql_select_db('Esgames4ulogin') or die(mysql_error());

	//set up the query
	$query = "SELECT * FROM users 
			WHERE user_name='$user_name' AND password='$password'";
	// Test output of something
	echo $query . "<br />\n";
		
	//run the query and get the number of affected rows
	$result = mysql_query($query, $connection) or die('error making query: ' mysql_error());

	//if there's exactly one result, the user is validated. Otherwise, he's invalid
	if(1 == mysql_num_rows($result)) {
		echo 'validated';
	}
	else {
		echo 'not valid';
	}
}
else
{
	echo 'There was nothing posted...';
}
?>
OK, finishing up: <?php echo date("m-d-Y g:i A"); ?>.
</body>
</html>

Posted: Thu Mar 23, 2006 5:02 pm
by Cheeseboy
I still get a blank page. I dont think its in the code. well if you guys have a login script ill just use it and trash this one. I got it from a tutorial anyways.

Posted: Thu Mar 23, 2006 5:07 pm
by Benjamin
Copy and past the code above into a new file and run it. You might have an invalid character entity in your existing file from another wysiwyg editor or something and you would have a hard time fixing it. What editor are you using?

Posted: Thu Mar 23, 2006 5:08 pm
by feyd
by blank page, do you mean there's no source sent at all? .. or the isn't any output in the source?

Run the following in a new file and tell us the results please.

Code: Select all

<?php

$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
$rg = (in_array(strtolower(ini_get('register_globals')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$de = (in_array(strtolower(ini_get('display_errors')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$so = (in_array(strtolower(ini_get('short_open_tag')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$eol = (isset($_SERVER['HTTP_HOST']) ? "<br />\n" : "\n");

$ec = array(
   'E_STRICT' => 2048,
   'E_ALL' => 2047,
   'E_USER_NOTICE' => 1024,
   'E_USER_WARNING' => 512,
   'E_USER_ERROR' => 256,
   'E_COMPILE_WARNING' => 128,
   'E_COMPILE_ERROR' => 64,
   'E_CORE_WARNING' => 32,
   'E_CORE_ERROR' => 16,
   'E_NOTICE' => 8,
   'E_PARSE' => 4,
   'E_WARNING' => 2,
   'E_ERROR' => 1,
);

$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
   if (($t & $v) == $v)
   {
      $e[] = $n;
      $t ^= $v;
   }
}
$er = $er . ' (' . implode(' | ', $e) . ')';

echo 'PHP Version ' . $ve . $eol;
echo 'PHP OS ' . $os . $eol;
echo 'Error Reporting ' . $er . $eol;
echo 'Register Globals ' . $rg . $eol;
echo 'Short Tags ' . $so . $eol;
echo 'Display Errors ' . $de . $eol;

?>

Posted: Thu Mar 23, 2006 5:11 pm
by RobertGonzalez
OK, lets begin the troubleshooting...

1. Is your cache clear?
2. Is the file in the right directory?
3. Is the file being called by a form submission?
4. Will another .php file in the same directory parse as expected?

Lets start with these and see if there is anything we can get from this problem. What do you say?

EDIT: This post seems so out of place after Feyd's post. Oh well, it's been a while for me... you know, getting outposted by Feyd.

<imagining>Two geeks in cowboy hats starin' at each other. Draw... er, I mean Post!</imagining>

Posted: Thu Mar 23, 2006 5:30 pm
by Cheeseboy
feyd heres your info i got.

Code: Select all

PHP Version 4.4.0
PHP OS Linux
Error Reporting 2047 (E_ALL)
Register Globals Off
Short Tags On
Display Errors Off

Im using kwrite by the way

Posted: Thu Mar 23, 2006 5:35 pm
by Cheeseboy
ok Everah:
Im searching for this on the server so do i still nedd to clear the cache? 1. Is your cache clear?
Yes 2. Is the file in the right directory?
i dont know 3. Is the file being called by a form submission?
Do you mean will another php file work? if so yes others will. 4. Will another .php file in the same directory parse as expected?

Posted: Thu Mar 23, 2006 5:56 pm
by feyd
I'm going to guess that your server is Apache. If so, save this as ".htaccess" in the directory (make sure to notice the leading period), if one exists, edit this into it.

Code: Select all

php_flag display_errors on
after you get that squared away, try to run your script again.

Posted: Thu Mar 23, 2006 6:42 pm
by Cheeseboy
ok, with the help of a friend i got the errors turned on and i get this in everah's code:

Code: Select all

Parse error: parse error, unexpected T_STRING in /var/www/Esgames4uweb/validate.php on line 31

Posted: Thu Mar 23, 2006 6:58 pm
by Benjamin

Code: Select all

$result = mysql_query($query, $connection) or die('error making query: ' . mysql_error());
Add a . it may need a concator.

Posted: Thu Mar 23, 2006 7:21 pm
by Cheeseboy
ok got this error now:

Code: Select all

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /var/www/Esgames4uweb/validate.php on line 36