Ahojte
PHP skript mi vyhadzuje túto chybu:
Citácia:
Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0
Skript vyzerá takto:
Citácia:
<? define("INCLUDED", true); include "db.php"; header('Content-Type: text/html; charset=windows-1250');
$real_sid = session_id();
if ($_POST["akcia"] == "login") {
if ($_POST["login"] != "" and $_POST["password"] != "") {
$login = $_POST["login"];
$password = md5($_POST["password"]);
$user = mysql_query("SELECT * FROM `users` WHERE login='$login' and password='$password' LIMIT 1", $link) or die ("Chyba!");
$num = mysql_num_rows($user);
if ($num == 1) {
$ip = $_SERVER["REMOTE_ADDR"];
$cas = time();
$sid = session_id();
$online = "1";
$time = time();
mysql_query("UPDATE `users` SET ping=\"".$time."\" WHERE login=\"".$login."\" LIMIT 1", $link);
mysql_query("UPDATE `users` SET last_ip=\"".$ip."\" WHERE login=\"".$login."\" LIMIT 1", $link);
mysql_query("UPDATE `users` SET last_login=\"".$cas."\" WHERE login=\"".$login."\" LIMIT 1", $link);
mysql_query("UPDATE `users` SET online=\"".$online."\" WHERE login=\"".$login."\" LIMIT 1", $link);
mysql_query("UPDATE `users` SET sid=\"".$sid."\" WHERE login=\"".$login."\" LIMIT 1", $link);
//definicia sessionov
$_SESSION["id"] = $user["id"];
$_SESSION["sid"] = $user["sid"];
$_SESSION["login"] = $user["login"];
$_SESSION["prihlaseny"] = "1";
echo "login";
} else {echo "bad_password";}
}
else
{echo "empty_field";}
}
?>
a súbor db.php takto:
Citácia:
<?php
if (!defined('INCLUDED')) die ('Fatal error.');
$link = mysql_pconnect ("localhost" , "root", "heslo") or die ("Nepodarilo sa spojiť zo serverom");
$db = mysql_select_db("chat", $link) or die ("Spojenie z databázov nefunguje");
// nastavenie znakovej sady
@mysql_query ("SET NAMES CP1250");
session_start();
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE login=\"".$_SESSION["login"]."\" LIMIT 1", $link));
?>
Neviete kde by mohla byť chyba? Moja verzia php je PHP 5.3.8.
Ďakujem
// pridané po 26 minútach od posledného príspevkuProblém som vyriešil: v php.ini som mal register_global = Off