Thank you pritaeas for prior assistance. I have another problem for someone. My query complains with this message "query was empty" and I can't undetstand why. Need help please see code below.


<?php
$db="freedomone";
$link = mysql_connect("");
if (!$link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());

$id=$_POST;
$FName=$_POST;
$LName=$_POST;
$PatientPhone=$_POST;
$FacName=$_POST;
$FacAddress=$_POST;
$PatRoom=$_POST;
$FacCity=$_POST;
$FacState=$_POST;
$FacZip=$_POST;
$FacPhone=$_POST;
$CaregiverName=$_POST;
$CaregiverContactPhone=$_POST;
$MedDispenseTime1=$_POST;
$MedDispenseTime2=$_POST;
$MedDispenseTime3=$_POST;
$MedDispenseTime4=$_POST;
$MedDispenseTime5=$_POST;
$MedDispenseTime6=$_POST;
$Month=$_POST;
$Year=$_POST;

mysql_query(" UPDATE Liberty SET firstname='$FName' , lastname='$LName' , PatientPhone='$PatientPhone' , FacName='$FacName' , FacAddress='$FacAddress' , PatRoom='$PatRoom' , FacCity='$FacCity' , FacState='$FacState' , FacZip='$FacZip' , FacPhone='$FacPhone' , CaregiverName='$CaregiverName' , CaregiverContactPhone='$CaregiverContactPhone' , MedDispenseTime1='$MedDispenseTime1' , MedDispenseTime2='$MedDispenseTime2' , MedDispenseTime3='$MedDispenseTime3' , MedDispenseTime4='$MedDispenseTime4' , MedDispenseTime5='$MedDispenseTime5' , MedDispenseTime6='$MedDispenseTime6' , Month='$Month' , Year='$Year' WHERE PatientID='$id");

/* The line below verifies query and it's returning the error "query was empty" */
$ret = mysql_query($query) or die(mysql_error());

echo "Record Updated";
mysql_close($link);
?>

Where is $query set? The line above is executing the query, without capturing the result. Looks like it should be replaced with:

$query = " UPDATE Liberty SET firstname='$FName' , lastname='$LName' , PatientPhone='$PatientPhone' , FacName='$FacName' , FacAddress='$FacAddress' , PatRoom='$PatRoom' , FacCity='$FacCity' , FacState='$FacState' , FacZip='$FacZip' , FacPhone='$FacPhone' , CaregiverName='$CaregiverName' , CaregiverContactPhone='$CaregiverContactPhone' , MedDispenseTime1='$MedDispenseTime1' , MedDispenseTime2='$MedDispenseTime2' , MedDispenseTime3='$MedDispenseTime3' , MedDispenseTime4='$MedDispenseTime4' , MedDispenseTime5='$MedDispenseTime5' , MedDispenseTime6='$MedDispenseTime6' , Month='$Month' , Year='$Year' WHERE PatientID='$id";

Where is $query set? The line above is executing the query, without capturing the result. Looks like it should be replaced with:

$query = " UPDATE Liberty SET firstname='$FName' , lastname='$LName' , PatientPhone='$PatientPhone' , FacName='$FacName' , FacAddress='$FacAddress' , PatRoom='$PatRoom' , FacCity='$FacCity' , FacState='$FacState' , FacZip='$FacZip' , FacPhone='$FacPhone' , CaregiverName='$CaregiverName' , CaregiverContactPhone='$CaregiverContactPhone' , MedDispenseTime1='$MedDispenseTime1' , MedDispenseTime2='$MedDispenseTime2' , MedDispenseTime3='$MedDispenseTime3' , MedDispenseTime4='$MedDispenseTime4' , MedDispenseTime5='$MedDispenseTime5' , MedDispenseTime6='$MedDispenseTime6' , Month='$Month' , Year='$Year' WHERE PatientID='$id";

I am a newby so I don't understand your statement "Where is $query set? The line above is executing the query, without capturing the result"

If you use code tags in future, I could refer to specific lines.

The following line uses the variable $query. This variable doesn't appear to be set, and is therefore likely the cause of your error.

$ret = mysql_query($query) or die(mysql_error());

Store the mysql query inside $query and it should do the trick.

$query = "UPDATE Liberty SET firstname='$FName' , lastname='$LName' , PatientPhone='$PatientPhone' , FacName='$FacName' , FacAddress='$FacAddress' , PatRoom='$PatRoom' , FacCity='$FacCity' , FacState='$FacState' , FacZip='$FacZip' , FacPhone='$FacPhone' , CaregiverName='$CaregiverName' , CaregiverContactPhone='$CaregiverContactPhone' , MedDispenseTime1='$MedDispenseTime1' , MedDispenseTime2='$MedDispenseTime2' , MedDispenseTime3='$MedDispenseTime3' , MedDispenseTime4='$MedDispenseTime4' , MedDispenseTime5='$MedDispenseTime5' , MedDispenseTime6='$MedDispenseTime6' , Month='$Month' , Year='$Year' WHERE PatientID='$id'";
mysql_query(" UPDATE Liberty

should be

$query=(" UPDATE Liberty
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.