login error

When i login as localhost this message displayed
Fatal error: Call to undefined function: mysql_real_escape_string() in C:apachehtdocsloginloginck.php on line 45
Why this message displyed find please
loginck.php file code is

<?
include "include/session.php";

$dbservertype='mysql';
$servername='localhost';
// username and password to log onto db server
$dbusername='';
$dbpassword='';
// name of database
$dbname='tutorial';

connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
//////////////////////////////
?>
<!doctype html public "-//w3c//dtd html 3.2//en">

<html>

<head>
<title>(Type a title for your page here)</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?
$userid=mysql_real_escape_string($userid);
$password=mysql_real_escape_string($password);

if($rec=mysql_fetch_array(mysql_query("SELECT * FROM plus_signup WHERE userid='$userid' AND password = '$password'"))){
	if(($rec['userid']==$userid)&&($rec['password']==$password)){
	 include "include/newsession.php";
            echo "<p class=data> <center>Successfully,Logged in<br><br><a href='logout.php'> Log OUT </a><br><br><a href=welcome.php>Click here if your browser is not redirecting automatically or you don't want to wait.</a><br></center>";
     print "<script>";
       print " self.location='welcome.php';"; // Comment this line if you don't want to redirect
          print "</script>";

				} 
		}	
	else {

		session_unset();
echo "<font face='Verdana' size='2' color=red>Wrong Login. Use your correct  Userid and Password and Try <br><center><input type='button' value='Retry' onClick='history.go(-1)'></center>";
		
	}
?>
<center>
<br><br><a href='http://www.plus2net.com'>PHP SQL HTML free tutorials and scripts</a></center> 

</body>

</html>

What PHP version are you running on?

I use PHP Version 4.0.5 please edit that code i want to use this version.

Did you read the PHP manual? The reason for the error is stated quite clearly in it.

For version 4.0.5 find error and replace it (what will be the code for this version). i want to use this version.

Then you can’t use mysql_real_escape_string(), as it was introduced in 4.3.0. Use a similar function that’s available in your PHP version. I’d say mysql_escape_string() should do the job.

You know that I am a very new in php. I collect a login script. That have signup, signupck, login, loginck, welcome include session and new session and logout file. My all file works well. My loginck file shows top of topics. I have index page, index page2. I want anybody can watch these pages by only login those who are registered. I cannot understand what should I have to do. Please solve. My welcome.php file is

<?
// This is downloaded from www.plus2net.com //

include "include/session.php";
?>
<!doctype html public "-//w3c//dtd html 3.2//en">

<html>

<head>
<title>(Type a title for your page here)</title>

<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?

echo "<center><font face='Verdana' size='2' >Welcome userid=$session[userid]<br><br>You must see your userid here (above) <br><br><br>Click <a href=logout.php>here to logout</a><br></center></font>";

?>
<center>
<br><br><a href='http://www.plus2net.com'>PHP SQL HTML free tutorials and scripts</a></center> 

</body>

</html>

Did you try contacting the person/website you got the script from for support? We don’t offer support on third-party scripts.

Sponsor our Newsletter | Privacy Policy | Terms of Service