i having some serious problems in getting the information out of a query. i have put up sufficient flags to know if the database is containing any information and to determine which path the code is taking. however i just cant get the information out
here is the code

if (!$_POST['submit'])
	{
	
			
					$hostname = "localhost";
					$username = "root";
					$password = "hayden";
					$database = "ecng3020";
					
					
					$con = mysql_connect("$hostname","$username","$password");
					if (!$con)
					  {
					  die('Could not connect: ' . mysql_error());
					  }
					  mysql_select_db("$database", $con);
					  
					// $sql= "SELECT  * FROM rules WHERE type='prerequisite' ";
					 //$result=mysql_query($sql);
					 
						
							
				
		// first access to form
		
				// checking if the record is in the database 
				 //$sql= "SELECT  * FROM rules WHERE type='prerequisite' ";
		$q = "SELECT first_name,last_name,password FROM students WHERE id_no='$c' ";	
		//if ($result=mysql_query($sql))
		
		
			
		
		
		
		
		if (!$result_1=mysql_query($q))
			{
				
				//extract($row);
				//$_POST['id']=$id_no;
				
				echo '<p>$row[0]</p>';
			//echo "error: user with id {$_GET['id']} does not exist, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue							 				</a>";	
			//exit;	
			}
			else
			{
			
				if (mysql_num_rows($result_1)!=0){
				echo "Found Information!";
				}else{
				echo "No Information Found!";}

				echo '<p>shit</p>';
				$row_1 = mysql_fetch_row($result_1);
				//extract($row_1);
				
					echo '<p>$row_1[0]</p>';
				
				$_POST['id']=$row['id_no'];
				$_POST['firstname']=$first_name;
				$_POST['last_name']=$last_name;
				$_POST['password']=$password;
				//$_POST['repassword']=$password;
				
				echo "<p>$row[id_no]</p>";
			
			}

the query in line 28 is giving me the echo statement that there in information in the database however this echo '<p>$row_1[0]</p>'; statement is just returning $row[0] on the screen which indicates to me it is empty
can some help me as to y this is so

A little something to play with:

<?php

$hostname = "localhost";
$username = "root";
$password = "hayden";
$database = "ecng3020";
if($_POST['id']) {
	$c = $_POST['id'];

	mysql_connect("$hostname","$username","$password") or die('Could not connect: ' . mysql_error());
	mysql_select_db($database);

// checking if the record is in the database 

	$q = "SELECT first_name,last_name,password FROM students WHERE id_no='$c' ";
	$result = mysql_query($q) or die('\"'.$q.'\" Query failed: ' . mysql_error());
	$row = mysql_fetch_array($result, MYSQL_BOTH);

	if (mysql_num_rows($result)!=0) {
		echo "Found Information!";
	}else{
		die("No Information Found!");
	}

	echo "<p>", $row['first_name'], "</p>";
	echo "<p>", $row['last_name'], "</p>";
	echo "<p>", $row['password'], "</p>";

} else {
	
?>
<form action="" method="post">
ID: <input type="text" name="id" maxlength="6" size="7" /><input type="submit" name="submit" value="Submit" />
</form>
<?php } ?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.