Получавам следната грешка
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/evgeni/public_html/mcf/register.php on line 39
Warning: Cannot modify header information - headers already sent by (output started at /home/evgeni/public_html/mcf/register.php:39) in /home/evgeni/public_html/mcf/register.php on line 51
Като 2-рата се показва дори и като сменя мястото на my_header( ' registration ' ); да е най отзад.
Ето целия ми код
<?php
session_start();
include ' functions.php ' ;
if(!$_SESSION[ ' is_logged ' ]==true)
{
if ($_POST[ ' form_submit ' ]==1)
{
$login=trim($_POST[ ' login ' ]);
$pas=trim($_POST[ ' pass ' ]);
$pas2=trim($_POST[ ' pass2 ' ]);
$email=trim($_POST[ ' mail ' ]);
$name=trim($_POST[ ' name ' ]);
if(strlen($login)<4)
{
$error_array[ ' login ' ]= ' Invalid Name ' ;
}
if(strlen($pas)<4)
{
$error_array[ ' pass ' ]= ' Short Password ' ;
}
if($pas!=$pas2)
{
$error_array[ ' pass ' ]= ' Password do not match ' ;
}
if(!eregi( " ^[a-z0-9_.-]*@[a-z0-9.-]+\\.[a-z]{2,4}$ " , $email ))
{
$error_array[ ' mail ' ]= ' Invalid e-mail address ' ;
}
if (!ereg( " ^[a-zA-Z]{3,16}$ " ,$name))
{
$error_array[ ' name ' ]= ' Invalid name ' ;
}
if (!count($error_array)>0)
{
db_init();
$sql= ' SELECT COUNT(*) as cnt FROM users WHERE login= " ' .addslashes($login). ' " OR email " ' .addslashes($email). ' " ' ;
$res=mysql_query($sql);
$row=mysql_fetch_assoc($res);
if($row[ ' cnt ' ]==0)
{
mysql_query( ' INSERT INTO users (login, pass, real_name, email, date_registered)
VALUES( " ' .addslashes($login). ' " , " ' .md5($pas). ' " , " ' .addslashes($name). ' " , " ' .addslashes($email). ' " , ' .time(). ' ) ' );
if(mysql_error())
{
echo ' <h1>Error, please try again</h1> ' ;
echo mysql_error();
}
else
{
header( ' Location: index.php ' );
exit;
}
}
else
{
$error_array[ ' login ' ]= ' Name or address are already in use ' ;
$error_array[ ' mail ' ]= ' Name or address are already in use ' ;
}
}
}
my_header( ' registration ' );
?>
<form action= " register.php " method= " post " >
Login: <input type= " text " name= " login " value= " " />
<?php
if($error_array[ ' login ' ])
{
echo ' Invalid Login ' ;
}
?>
Password: <input type= " text " name= " pass " value= " " />
<?php
if($error_array[ ' pass ' ])
{
echo ' Invalid Password ' ;
}
?>
Repeat Password: <input type= " text " name= " pass2 " value= " " />
Email: <input type= " text " name= " mail " value= " " />
<?php
if($error_array[ ' email ' ])
{
echo ' Invalid E-mail ' ;
}
?>
Real name: <input type= " text " name= " name " value= " " />
<?php
if($error_array[ ' name ' ])
{
echo ' Invalid Name ' ;
}
?>
<input type= " hidden " name= " form_submit " value= " 1 " />
<input type= " submit " name= " submit " value= " Register yourself " />
</form>
<?php
footer();
}
else
{
header( ' Location= index.php ' );
exit;
}
?>
знам че темата е стара но се надявам някой да я види!