Jump to content

Mysql Error From An Anchor Tag?


cadius

Recommended Posts

Heya,Just added this anchor into my code:

<a href="reset.php">Forgotten your password?</a>

On clicking the link in the browser, I get a 404 page not found error, the 'reset.php' is there, but I noticed my error file which had this to say:PHP Warning: mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]All my php tags are closed, so any ideas?

Link to comment
Share on other sites

I think we need to see some surrounding code, or reset.php, there's not really much to go on here.

Link to comment
Share on other sites

Fair enough, heres all the code for the page.

<?phprequire_once('db.fun.php');$type = isset($_POST['type']) ? $_POST['type'] : '';$email = $_POST['email'];$pass = $_POST['pass'];$error_reg = '';$error_log = '';switch ($type){	case 'reg':		if ( $email =='' )		{			$error_reg = 'You have not entered an email address.';		}		else		{			mysql_connect($hostname,$username,$sqlpass) OR DIE ('Cannot connect to server!' .mysql_error());			mysql_select_db($dbname) OR DIE ('Cannont connect to the database!' .mysql_error());			$email = trim($email);			$email = mysql_real_escape_string($email);			$sql = "SELECT email FROM game_user WHERE email = '$email'";			$result = mysql_query($sql);			$stuff = mysql_num_rows($result);			if ($stuff > 0)			{				$error_reg = 'Sorry That email address is already registered.';			}			else			{				$temppass = md5(uniqid(rand()));				$sql = "INSERT INTO game_user (email,password) VALUES ('$email','$temppass')";				$result = mysql_query($sql);				if ($result)				{					$to = $email;					$subject = "Grand Prince Confirmation";					$header = "From: Staff @ GrandPrince";					$message="Your activation link \r\n";					$message.="Click on the below link to activate your account \r\n";					$message.="http://www.haydiekeys.com/gp/confirm.php?id=$temppass";					$send = mail($to,$subject,$message,$header);					$error_reg = 'An email has been sent, check your email to activate your account.';				}				else				{					$error_reg = 'We are unable to send your confirmation email, please try again.';				}			}		}		break;	case 'log':		session_start();		if ($_SESSION['login'] == true)		{			redirect('main.php');		} 		else 		{			if ($email == '' || $pass == '' )			{				$error_log = 'You have not entered your email or password';			}			else			{ 				mysql_connect($hostname,$username,$sqlpass) OR DIE ("Cannot connect to Database!"); 				mysql_select_db($dbname) OR DIE ("Cannot connect to the Database!"); 				$email = trim($email);				$pass = trim($pass);				$email = mysql_real_escape_string($email);				$pass = mysql_real_escape_string($pass);				$sql	= "SELECT * FROM game_user WHERE email = '$email' AND password = '$password'";				$result = mysql_query($sql);				$found = mysql_num_rows($result);				if ($found == 2)				{					$_SESSION['login'] = true;					redirect('main.php');				}				else				{					$error_log = 'You dont appear to be registered.';				}			}		}		break;}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link rel="stylesheet" type="text/css" href="style.css" /></head><body><h1>Welcome!</h1><p>Welcome to my little game.</p><p><div class="error_text"><?php echo $error_reg; ?></div>	<form action="index.php" method="post">	Your email:<input type="text" name="email" size="30" maxlength="255"><br />	<input type="submit" name="submit" value="Register!" />	<input type="hidden" name="type" value="reg">	</form></p><p><div class="error_text"><?php echo $error_log; ?></div>	<form method="post" action="index.php">	Your email:<input type="text" name="email" size="30" maxlength="255"><br />	Your Password:<input type="password" name="pass" size="30" maxlength="255"><br />	<input type="submit" name="login" value="Log In" />	<input type="hidden" name="type" value="log" /><div class="error_text"><?php echo $error_txt; ?></div></p><p><a href="reset.php">Forgotten your password?</a></p></body></html>

Link to comment
Share on other sites

Are you sure redirect('main.php'); is a real function? Maybe you meant header("Location: main.php").Is it that page or reset.php that has the problem?

Link to comment
Share on other sites

Also, just to point out - Internet Explorer doesn't show the PHP errors by default, it shows a generic error page. You can either use a different browser to test with which will actually show the error message, or you can go into IE's settings and disable "Friendly HTTP Errors", which although they may be friendly, are useless to developers.

Link to comment
Share on other sites

Thanks all,RahXephon, its a function, but I hadn't included it, so I'm thinking your proberbly right there, but have re-planned my code layout, being a newbie, theres no point me trying to make things more complicated than they should be. But thanks again for your input. :)justsomeguy, I'm a recent iMac convert, so I'm currently running Safari, but I'll have a look around and see what I can tweak. Should be a similar setting somewhere. Thanks for the info.

Link to comment
Share on other sites

I'm actually not sure if Safari does the same thing as IE or not (perish the thought). I guess it's easy enough to test though. If you run this script you should see an error message from PHP:

<?phptrigger_error('This is an error message', E_USER_ERROR);?>

If you see that error message printed then it should be fine, if the browser displays its own error page then you probably want to disable that if you can.

Link to comment
Share on other sites

Heya Justsomeguy,Tried that little code piece, and sure enough it worked, I could see the php error.So I kept hitting the link and kept getting the 404 error (it might just magically work if I keep hitting it... ). So I thought, the files there on the server ( according to my ftp-client ), but it wont link, so lets see if the page is really there, and not a ghost. So I've typed in the http address into the address bar, and it came up as the actual page, not a 404 error... so no ghost. So it is there and usable, so I went to the main page again, and hit the link (out of frustration!) and it worked? Now this seems all a little strange and non-logical to me, in my limited experience in coding.Any thoughts or suggestions on the matter?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...