помогнете за грешка

vesku

Registered
искарва ми тапа грашка в този код
тя е
Parse error: parse error, unexpected T_VARIABLE in C:\wamp\www\changepass.php on line 22
Код:
<?php
session_start();
$_SESSION['username'] = $username;
if (isset($HTTP_SESSION_VARS['username']))
{
echo ('
<form method=post action="index.php">
New password:<br>
<input type=text name=new_password><br>
Repeat new password:<br>
<input type="text" name="repeat_password"><br>
<input type="submit" name="change" value="Change password">
</form>
');
}
if ($new_password!=$repeat_password) 
   echo "<br>Passwords not changed."; 
else
{
include "config.php";
$pass = '$_POST[new_password]'
$query = "update users set password = where $username = 

$_SESSION['username']";
$result = mysql_query($query, $db_conn);
echo "Password Changed";
}
} else { echo "Нямате достъп до тази страница!";

exit;
}
?>
 

NetCutter

Registered
Еми нормално е, трябва да е така!
Код:
<?php
session_start();
$_SESSION['username'] = $username;
if (isset($HTTP_SESSION_VARS['username']))
{
echo ('
<form method=post action="index.php">
New password:<br>
<input type=text name=new_password><br>
Repeat new password:<br>
<input type="text" name="repeat_password"><br>
<input type="submit" name="change" value="Change password">
</form>
');
}
if ($new_password!=$repeat_password)
   echo "<br>Passwords not changed.";
else
{
include "config.php";
$pass = '$_POST[new_password]';
$query = "update users set password = where $username =

$_SESSION['username']";
$result = mysql_query($query, $db_conn);
echo "Password Changed";
}
} else { echo "Нямате достъп до тази страница!";

exit;
}
?>
След карая на $pass трябва да има една ;
 

vesku

Registered
NetCutter каза:
Еми нормално е, трябва да е така!
Код:
<?php
session_start();
$_SESSION['username'] = $username;
if (isset($HTTP_SESSION_VARS['username']))
{
echo ('
<form method=post action="index.php">
New password:<br>
<input type=text name=new_password><br>
Repeat new password:<br>
<input type="text" name="repeat_password"><br>
<input type="submit" name="change" value="Change password">
</form>
');
}
if ($new_password!=$repeat_password)
   echo "<br>Passwords not changed.";
else
{
include "config.php";
$pass = '$_POST[new_password]';
$query = "update users set password = where $username =

$_SESSION['username']";
$result = mysql_query($query, $db_conn);
echo "Password Changed";
}
} else { echo "Нямате достъп до тази страница!";

exit;
}
?>
След карая на $pass трябва да има една ;
така дава това
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\changepass.php on line 22
 

vesku

Registered
ето истинския код сори ама бях забравил във update на mysql да сложа това
$pass проблема пак си остава
Код:
<?php
session_start();
$_SESSION['username'] = $username;
if (isset($HTTP_SESSION_VARS['username']))
{
echo ('
<form method=post action="index.php">
New password:<br>
<input type=text name=new_password><br>
Repeat new password:<br>
<input type="text" name="repeat_password"><br>
<input type="submit" name="change" value="Change password">
</form>
');
}
if ($new_password!=$repeat_password) 
   echo "<br>Passwords not changed."; 
else
{
include "config.php";
$pass = '$_POST[new_password]'
$query = "update users set password = $pass where $username = 

$_SESSION['username']";
$result = mysql_query($query, $db_conn);
echo "Password Changed";
}
} else { echo "Нямате достъп до тази страница!";

exit;
}
?>
 

NetCutter

Registered
Я пробвай така:
Код:
<?php
session_start();
$_SESSION['username'] = $username;
if (isset($HTTP_SESSION_VARS['username']))
{
echo ('
<form method=post action="index.php">
New password:<br>
<input type=text name=new_password><br>
Repeat new password:<br>
<input type="text" name="repeat_password"><br>
<input type="submit" name="change" value="Change password">
</form>
');
}
if ($new_password!=$repeat_password)
   echo "<br>Passwords not changed.";
else
{
include "config.php";
$pass = $_POST[new_password];
$query = "update users set password = where $username =

$_SESSION['username']";
$result = mysql_query($query, $db_conn);
echo "Password Changed";
}
} else { echo "Нямате достъп до тази страница!";

exit;
}
?>
 

bafitu

Registered
а така :
Код:
<?php
session_start();
$_SESSION['username'] = $username;
if (isset($HTTP_SESSION_VARS['username']))
{
echo ('
<form method=post action="index.php">
New password:<br>
<input type=text name=new_password><br>
Repeat new password:<br>
<input type="text" name="repeat_password"><br>
<input type="submit" name="change" value="Change password">
</form>
');
}
if ($new_password!=$repeat_password){
   echo "<br>Passwords not changed.";}
else
{
include "config.php";
$pass = $_POST[new_password];
$query = "update users set password = where $username =

$_SESSION['username']";
$result = mysql_query($query, $db_conn);
echo "Password Changed";
}
 else { echo "Нямате достъп до тази страница!";

exit;
}
?>
 

bafitu

Registered
мисля , че имаш грешка с заявката..
Код:
<?php
session_start();
$_SESSION['username'] = $username;
if (isset($HTTP_SESSION_VARS['username']))
{
echo ('
<form method=post action="index.php">
New password:<br>
<input type=text name=new_password><br>
Repeat new password:<br>
<input type="text" name="repeat_password"><br>
<input type="submit" name="change" value="Change password">
</form>
');
}
if ($new_password!=$repeat_password){
   echo "<br>Passwords not changed.";}
else
{
include "config.php";
$pass = $_POST[new_password];
$query = "update users set password = $pass where username =
$_SESSION['username']";
$result = mysql_query($query, $db_conn);
echo "Password Changed";
}
 else { echo "Нямате достъп до тази страница!";

exit;
}
?>
я пробвай така.. сега трябва да ъпдейтне в бд-то паролата където юсернейма е деклариран в сесията...
 

vesku

Registered
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\changepass.php on line 22
е на бафиту
 

vesku

Registered
направих го така но изписва това
Parse error: parse error, unexpected T_STRING in C:\wamp\www\cp.php on line 24
Код:
<?php
session_start();
$_SESSION['username'] = $username;
if (isset($HTTP_SESSION_VARS['username']))
{
echo ('
<form method=post action="index.php">
New password:<br>
<input type=text name=new_password><br>
Repeat new password:<br>
<input type="text" name="repeat_password"><br>
<input type="submit" name="change" value="Change password">
</form>
');
}
else
{
echo "Нямате достъп до тази страница!";
}
exit;
if ($new_password==$repeat_password){
{
include "config.php";
$query = update users set 'password = $_POST[new_password]' where 'username = $username';
$result = mysql_query($query, $db_conn);
echo "Password Changed";
}
else
{
echo "<br>Passwords not changed.";
}
?>
 

bafitu

Registered
$query = "update users set password = '$_POST[new_password]' where username = '$username'";
е толкова ли неможа да сложиш едни кавички.. :roll:
 

NetCutter

Registered
А някой да забеляза това:
if ($new_password==$repeat_password){
{

include "config.php";
$query = update users set 'password = $_POST[new_password]' where 'username = $username';
$result = mysql_query($query, $db_conn);
echo "Password Changed";
}
Едното е излишно :wink:
т.е.: ето как трябва да ти изглежда кода:
Код:
<?php
session_start();
$_SESSION['username'] = $username;
if (isset($HTTP_SESSION_VARS['username']))
{
echo ('
<form method=post action="index.php">
New password:<br>
<input type=text name=new_password><br>
Repeat new password:<br>
<input type="text" name="repeat_password"><br>
<input type="submit" name="change" value="Change password">
</form>
');
}
else
{
echo "Нямате достъп до тази страница!";
}
exit;
if ($new_password==$repeat_password)
{
include "config.php";
$query = update users set 'password = $_POST[new_password]' where 'username = $username';
$result = mysql_query($query, $db_conn);
echo "Password Changed";
}
else
{
echo "<br>Passwords not changed.";
}
?>
 

vesku

Registered
ЕДИТ: заради това изкарва грешката ве мн сам тъп
Код:
$query = update users set 'password = $_POST[new_password]' where 'username = $username';
трябва да стане така


Код:
[color=red]$query = mysql_query("update users set 'password = $_POST[new_password]' where 'username = $username'");[/color]


ето това изкарва така
Parse error: parse error, unexpected T_STRING in C:\wamp\www\cp.php on line 24
NetCutter каза:
А някой да забеляза това:
if ($new_password==$repeat_password){
{

include "config.php";
$query = update users set 'password = $_POST[new_password]' where 'username = $username';
$result = mysql_query($query, $db_conn);
echo "Password Changed";
}
Едното е излишно :wink:
т.е.: ето как трябва да ти изглежда кода:
Код:
<?php
session_start();
$_SESSION['username'] = $username;
if (isset($HTTP_SESSION_VARS['username']))
{
echo ('
<form method=post action="index.php">
New password:<br>
<input type=text name=new_password><br>
Repeat new password:<br>
<input type="text" name="repeat_password"><br>
<input type="submit" name="change" value="Change password">
</form>
');
}
else
{
echo "Нямате достъп до тази страница!";
}
exit;
if ($new_password==$repeat_password)
{
include "config.php";
$query = update users set 'password = $_POST[new_password]' where 'username = $username';
$result = mysql_query($query, $db_conn);
echo "Password Changed";
}
else
{
echo "<br>Passwords not changed.";
}
?>
Код:
$query = update users set 'password = $_POST[new_password]' where 'username = $username';
[/code]
 

Горе