Error when trying to pull information from Mysql into PHP (Edit info)

Hi all

I have hospital DB that have many tables. one of them is Patient’s table.Doctor can Edit some info of patient like Blood Type Weight and more

from the Doctor Page you can see all patients info and there is “Edit” link witch allow you to open new page and pull info from DB and edit info then save it.

When I Press “Edit” I get this error
Query was empty
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\project\DoctorEditPatient.php on line 24

these are the code

doctor.php
[php]<?php
session_start();
$Name = $_SESSION[‘Name’];
//echo “Welcome to Doctor page”;
echo $Name;

$localhost = ‘localhost’;
$dusername = ‘root’;
$dpassword = ‘root’;
$database = ‘hospital’;
$connection = new mysqli($localhost , $dusername , $dpassword,$database);
if ($connection->connect_error) {
die("Connection failed: " . $conn->connect_error);
echo “No Connection to DB”;
}
//echo “Connected successfully”;
echo “

”;

//$Name = $_POST[‘uname’];
//$Pass = $_POST[‘psw’];
$aEmpID = $_SESSION[‘aEmpID’];
//echo $aEmpID;
echo “

”;
 $quiry = "SELECT  PatientID , Fname , Lname , BloodType , Sex , Weight , Height , Vitals  from patient where EmpID = '$aEmpID'";

$result = mysqli_query($connection, $quiry);
//echo $result;
echo “

”;
if (!$result)
{
die("Query Faile".  mysqli_errno($connection));   

}

if ($result->num_rows > 0) {
// output data of each row
echo “

”;
   echo "<tr>";
   echo "<td>PatientID</td>";
   echo "<td>First Name</td>";
   echo "<td>Last Name</td>";
   echo "<td>BloodType</td>";
   echo "<td>Sex</td>";
   echo "<td>Weight</td>";
   echo "<td>Height</td>";
   echo "<td>Vitals</td>";
	echo "</tr>";
while($row = $result->fetch_assoc()) {
   $PatientID = $row['PatientID'];
   $Fname =  $row['Fname'];
   $Lname =  $row['Lname'];
   $BloodType =  $row['BloodType'];
   $Sex =  $row['Sex'];
   $Weight =  $row['Weight'];
   $Height =  $row['Height'];
   $Vitals =  $row['Vitals'];

	
   echo "<tr>";
   echo "<td>$PatientID</td>";
   echo "<td>$Fname</td>";
   echo "<td>$Lname</td>";
   echo "<td>$BloodType</td>";
   echo "<td>$Sex</td>";
   echo "<td>$Weight</td>";
   echo "<td>$Height</td>";
   echo "<td>$Vitals</td>";
  echo "<td colspan='2'>". "<a href = 'DoctorEditPatient.php?Edit=$row[PatientID]'>Edit</a>".  "</td>";
   //echo "<br>";
   echo "</tr>";
	
}

} else {

	echo "There is no patients";
	//header("location:regist.html");

//echo "0 results";
echo "</table>";

}

?>[/php]

DoctorEditPatient.php

[php]<?php
session_start();

$localhost = ‘localhost’;
$dusername = ‘root’;
$dpassword = ‘root’;
$database = ‘hospital’;
$connection = new mysqli($localhost , $dusername , $dpassword,$database);

if (isset($_GET[‘Edit’]))
{

$PID = $_GET['Edit'];
//echo $PID;
$que = mysql_query("Select * FROM patient WHERE PatientID = '$PID'");


//echo $row;

//$result = mysqli_query($connection, $que) or die ( mysqli_error());
$record = mysql_query($que) or print(mysql_error());

$row = mysql_fetch_array($que);

}

if (isset($_POST[‘PatientID’]))
{
echo “4”;

//	$make = $_POST["car-makes"];

	$BloodType = mysql_real_escape_string($_POST["BloodType"]);
	//$comment = mysql_real_escape_string($_POST["txt"]);

	
//	$image= addslashes($_FILES['image']['tmp_name']);
	//$name= addslashes($_FILES['image']['name']);
	//$image= file_get_contents($image);
	//$image= base64_encode($image);

$que1 =  "UPDATE patient SET BloodType ='$BloodType'";
$record = mysql_query($que1) or print(mysql_error());
//echo "<meta http-equiv='refresh' content = '0;url=dealer.php'>";

//iterate over all the rows
if($record === FALSE)

echo $record;

}
?>

Edit Patient

<label><b> BloodType </b></label>
<input type="text" name="BloodType" value="<?php echo $row[BloodType]; ?>" >
    <br></br>

Save

[/php]

Why are you mixing obsolete mysql code with Mysqli? And stop creating variables for nothing.

Tell me this is a school project? This is the specific field I develop for and there are so many things wrong here!

Sponsor our Newsletter | Privacy Policy | Terms of Service