gaspare100 Posted June 18, 2009 Share Posted June 18, 2009 this is the code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Tribuguadagno!</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <?php session_start(); function sql_quote( $value ) { if( get_magic_quotes_gpc() ) { $value = stripslashes( $value ); } //check if this function exists if( function_exists( "mysql_real_escape_string" ) ) { $value = mysql_real_escape_string( $value ); } //for PHP version < 4.3.0 use addslashes else { $value = addslashes( $value ); } return $value; } if (isset($_POST['username'])) { $username = sql_quote($_POST['username']); $password = sql_quote($_POST['password']); $mysqli = new mysqli("localhost", "root", "", "tribuguadagno"); $risultato = $mysqli->query("SELECT * FROM users WHERE userid='$username' AND password='$password'"); $mysqli->close(); if ($risultato->num_rows == 0){ header("location: index.php"); exit; } session_start(); $_SESSION['user'] = $username; header("location: index.php"); } if (isset($_GET['logout'])) { session_unset(); session_destroy(); header("location: index.php"); exit; } if (isset($_SESSION['user'])) { echo ('You are logged in!'); echo ('<br><a href=\'?logout\'>Log out</a>'); } else { echo('<h2>Member Login</h2><form action="cpanel.php" method="POST">Username:<br><input type="text" name="username"><br>Password:<br><input type="password" name="password"><br><input type="submit" name="submit" value="login"></form>'); } ?> </body> </html> and this is the output i get (HTML source code) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Tribuguadagno!</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> query("SELECT * FROM users WHERE userid='$username' AND password='$password'"); $mysqli->close(); if ($risultato->num_rows == 0){ header("location: index.php"); exit; } session_start(); $_SESSION['user'] = $username; header("location: index.php"); } if (isset($_GET['logout'])) { session_unset(); session_destroy(); header("location: index.php"); exit; } if (isset($_SESSION['user'])) { echo ('You are logged in!'); echo ('<br><a href=\'?logout\'>Log out</a>'); } else { echo('<h2>Member Login</h2><form action="cpanel.php" method="POST">Username:<br><input type="text" name="username"><br>Password:<br><input type="password" name="password"><br><input type="submit" name="submit" value="login"></form>'); } ?> </body> </html> basically, the script is no longer parsed when it encounters a ">"... no a ?>, just a single > that i have to use in $mysqli->query .... anyone knows how to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/162821-solved-php-script-is-not-parsed-correctly/ Share on other sites More sharing options...
DavidAM Posted June 18, 2009 Share Posted June 18, 2009 I can't see anything to cause the parse issue. However, session_start() must be called BEFORE anything is sent to the browser. Where you have it, it is causing an error, which you are not seeing. Add the following to the very top of the file (before even the DOCTYPE): <?php error_reporting(E_ALL); session_start(); ?> Then you will see the error messages. Note, you will have to remove the other session_start() calls that you have in the file. Post the error message you get and maybe we can help. Quote Link to comment https://forums.phpfreaks.com/topic/162821-solved-php-script-is-not-parsed-correctly/#findComment-859281 Share on other sites More sharing options...
MadTechie Posted June 18, 2009 Share Posted June 18, 2009 change the file with the php code from .html to .php Quote Link to comment https://forums.phpfreaks.com/topic/162821-solved-php-script-is-not-parsed-correctly/#findComment-859284 Share on other sites More sharing options...
gaspare100 Posted June 19, 2009 Author Share Posted June 19, 2009 the file is a .php, and the error is not showing, the php doesn't parse that part at all. ( i set my php.ini to E_ALL to check, nothing appears) EDIT: i did some other tests, while all the other pages that i created on my local host works just fine, on this page NO php scripts will work... i even tryed adding this: <?php echo('test'); ?> to the top of the file (before anything) and nothing shows up. the other pages hosted work fine. i'm using XAMPP last version (1.7).... any tips? Quote Link to comment https://forums.phpfreaks.com/topic/162821-solved-php-script-is-not-parsed-correctly/#findComment-859751 Share on other sites More sharing options...
PFMaBiSmAd Posted June 19, 2009 Share Posted June 19, 2009 Does any php code in any file work or is it only the file you posted? Does the following by itself in a .php file work - <?php phpinfo(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/162821-solved-php-script-is-not-parsed-correctly/#findComment-859755 Share on other sites More sharing options...
gaspare100 Posted June 19, 2009 Author Share Posted June 19, 2009 Does any php code in any file work or is it only the file you posted? Does the following by itself in a .php file work - <?php phpinfo(); ?> it works on other files, not on this one. Wtf? Quote Link to comment https://forums.phpfreaks.com/topic/162821-solved-php-script-is-not-parsed-correctly/#findComment-859757 Share on other sites More sharing options...
PFMaBiSmAd Posted June 19, 2009 Share Posted June 19, 2009 The characters making up the php tag could be corrupted; the character encoding or the file it self could be corrupted; the characters making up the .php extension could be corrupted. Create a new file and copy/paste the contents of the existing file into it. Quote Link to comment https://forums.phpfreaks.com/topic/162821-solved-php-script-is-not-parsed-correctly/#findComment-859760 Share on other sites More sharing options...
gaspare100 Posted June 19, 2009 Author Share Posted June 19, 2009 Thanks it worked. Seriously, how could it happen? -.-''' Quote Link to comment https://forums.phpfreaks.com/topic/162821-solved-php-script-is-not-parsed-correctly/#findComment-859766 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.