Thx
Need professional help!
Moderator: General Moderators
Need professional help!
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.
Thx
Thx
Did you set
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?
Code: Select all
ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);Which html tags?
As long as you seperate the html and php itis ok
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.
As long as you seperate the html and php itis ok
Code: Select all
<?php
// this is php
$var = 'this';
?>
<h2>Normal html</h2>Code: Select all
<?php
$name = $_POST['name'];
var_dump($name);
// etc
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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.
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;
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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>
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>
feyd heres your info i got.
Im using kwrite by the way
Code: Select all
PHP Version 4.4.0
PHP OS Linux
Error Reporting 2047 (E_ALL)
Register Globals Off
Short Tags On
Display Errors OffIm using kwrite by the way
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?
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?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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.after you get that squared away, try to run your script again.
Code: Select all
php_flag display_errors onok, 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 31Code: Select all
$result = mysql_query($query, $connection) or die('error making query: ' . mysql_error());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