0

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);
?>

Edited by hhall56: n/a

4
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by facarroll
1

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";
0

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"

0

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());
0

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'";
0
mysql_query(" UPDATE Liberty

should be

$query=(" UPDATE Liberty

Edited by facarroll: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.