Page 1 of 1

Maybe concatation problem

Posted: Sat Nov 25, 2006 8:36 am
by a94060
Hello all,

I am trying to echo the variable $sql at the end. The problem is,i can echo sql if i dont set it for anything,but if i do,it does not echo,here is the code:

Code: Select all

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Proxy Logon</title>
</head>

<body>
<div align="center">
  <p>Welcome To the Logon Page</p>
  <p>&nbsp;</p>
  <form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
    <label>Hash
      <input name="hash" type="text" size="6" maxlength="6" />
    </label>
    <p>
      <label>
      <input type="Submit" name="Submit" value="Submit" />
      </label>
    </p>
  </form>
  <p>&nbsp; </p>
  <?php
 //start PHP HERE
 $submit = $_POST['Submit'];
 $hash = $_POST['hash'];
  if (isset($submit) && isset($hash)) {
  echo $hash;
  //check to see if it is a valid code
  include "sql.php";
  $sql = "SELECT time_left FROM times WHERE hash = .$hash. AND time_left > 0";
  $query = mysql_query($sql);
  $result = mysql_num_rows($query);
  echo $sql;
  

  }

 ?>
</div>
</body>
</html>
I know tgar the submit is getting set. Im not really sure about the hash,because once i submit it,nothing shows up. Help anyone?
Thanks

Posted: Sat Nov 25, 2006 9:39 am
by volka
try

Code: Select all

<!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>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>Proxy Logon</title>
	</head>

	<body>
<?php
if ( isset($_POST['Submit'], $_POST['hash']) ) {
	require 'sql.php';
	
	$hash = mysql_real_escape_string($_POST['hash']);
	$sql = "SELECT time_left FROM times WHERE hash='$hash' AND time_left > 0";
	echo '<div>Debug: ', htmlentities($sql), "</div>\n";
	
	$query = mysql_query($sql) or die(mysql_error());
	$result = mysql_num_rows($query);
	
	// while ( $row=mysql_fetch...
}
?>
		<div align="center">
			<p>Welcome To the Logon Page</p>
			<p>&nbsp;</p>
			<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
				<label>Hash
					<input name="hash" type="text" size="6" maxlength="6" />
				</label>
				<p>
					<label>
						<input type="Submit" name="Submit" value="Submit" />
					</label>
				</p>
			</form>
			<p>&nbsp; </p> 
		</div>
	</body>
</html>

Posted: Sat Nov 25, 2006 10:26 am
by a94060
allright,i think i fixed the problem then,thanks,i tried another soulution before this,it was a problem with what i was using in mysql_num_rows. I needed to add a link identifier and then the script worked pretty much.

thanks though