Having trouble updating database, I have this code and it keeps saying that the query was empty. I am trying to display multiple records from mysql into a form that I can submit individually, but I keep getting the query was empty phrase, please help.
<?php
mysql_connect("");
mysql_select_db("");
$sql = "SELECT * FROM KEYCAD WHERE Hold LIKE 'N' ORDER BY ContactDate DESC";
$result = mysql_query($sql);
if (mysql_errno()) die(mysql_error());
echo "<form method='post' action='submit.php?action=change'>\n";
while ($currentRow = mysql_fetch_array($result)) {
echo "<table border=2 bordercolor=#5E3964>\n";
echo "<tr>
<td><font color=#FF0000>Name</font></td>
<td><font color=#FF0000>Home #</font></td>
<td><font color=#FF0000>Work #</font></td>
<td><font color=#FF0000>Car Model</font></td>
</tr>\n";
printf("
<tr>
<input type='hidden' name='RO' value='%s'>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>\n",
$currentRow["RO"],
$currentRow["CUSTOMER NAME"],
$currentRow["HOMEPHONE"],
$currentRow["BUSPHONE"],
$currentRow["MODEL"]
);
echo "<tr>
<td><font color=#FF0000>Follow-Up Needed</font></td>
<td><font color=#FF0000>Customer Not Reached</font></td>
<td><font color=#FF0000>Fixed Correctly?</font></td>
<td><font color=#FF0000>Treatment?</font></td>
</tr>\n";
printf("
<tr>
<td><input type=checkbox name='FollowUpContact' value='1'></td>
<td><input type=checkbox name='CustomerNotReached' value='1'></td>
<td><input type=text name='Q1' value='%s'></td>
<td><input type=text name='Q2' value='%s'></td>
</tr>\n",
$currentRow["FollowUpContact"],
$currentRow["CustomerNotReached"],
$currentRow["Q1"],
$currentRow["Q2"]
);
echo "<tr>
<td><font color=#FF0000>Clear Explanation?</font></td>
<td><font color=#FF0000>Overall Service?</font></td>
<td><font color=#FF0000>Why Not Fixed?</font></td>
<td><font color=#FF0000>Labor Code</font></td>
</tr>\n";
printf("
<tr>
<td><input type=text name='Q3' value='%s'></td>
<td><input type=text name='Q4' value='%s'></td>
<td><input type=text name='Q5' value='%s'></td>
<td><input type=text name='LaborCode' value='%s'></td>
</tr>\n",
$currentRow["Q3"],
$currentRow["Q4"],
$currentRow["Q5"],
$currentRow["LaborCode"]
);
echo "<tr>
<td><font color=#FF0000>Comments</font></td>
<td><font color=#FF0000>Happy</font></td>
<td><font color=#FF0000>Close Date</font></td>
<td></td>
</tr>\n";
printf("
<tr>
<td><input type=text name='Comments' value='%s'></td>
<td><input type=checkbox name='HAPPY' value='%s'></td>
<td>%s</td>
<td><input type=Submit name='submit' value=Submit></td>
</tr>
</form></table>\n",
$currentRow["Comments"],
$currentRow["HAPPY"],
$currentRow["CLOSEDATE"]
);
}
?>
Here is the submit.php
<?php
$RO = $_POST['RO'];
echo "With $HTTP_POST_VARS " . $RO . "<BR>";
echo "With $_POST " . $_POST['RO'] . "<br>";
$CUSTOMERNAME = $HTTP_POST_VARS['CUSTOMERNAME'];
echo "With $HTTP_POST_VARS " . $CUSTOMERNAME . "<BR>";
echo "With $_POST " . $_POST['CUSTOMERNAME'] . "<br>";
$HOMEPHONE = $HTTP_POST_VARS['HOMEPHONE'];
echo "With $HTTP_POST_VARS " . $HOMEPHONE . "<BR>";
echo "With $_POST " . $_POST['HOMEPHONE'] . "<br>";
$BUSPHONE = $HTTP_POST_VARS['BUSPHONE'];
echo "With $HTTP_POST_VARS " . $BUSPHONE . "<BR>";
echo "With $_POST " . $_POST['BUSPHONE'] . "<br>";
$MODEL = $HTTP_POST_VARS['MODEL'];
echo "With $HTTP_POST_VARS " . $MODEL . "<BR>";
echo "With $_POST " . $_POST['MODEL'] . "<br>";
$FollowUpContact = $HTTP_POST_VARS['FollowUpContact'];
echo "With $HTTP_POST_VARS " . $FollowUpContact . "<BR>";
echo "With $_POST " . $_POST['FollowUpContact'] . "<br>";
$CustomerNotReached = $HTTP_POST_VARS['CustomerNotReached'];
echo "With $HTTP_POST_VARS " . $CustomerNotReached . "<BR>";
echo "With $_POST " . $_POST['CustomerNotReached'] . "<br>";
$Q1 = $HTTP_POST_VARS['Q1'];
echo "With $HTTP_POST_VARS " . $Q1 . "<BR>";
echo "With $_POST " . $_POST['Q1'] . "<br>";
$Q2 = $HTTP_POST_VARS['Q2'];
echo "With $HTTP_POST_VARS " . $Q2 . "<BR>";
echo "With $_POST " . $_POST['Q2'] . "<br>";
$Q3 = $HTTP_POST_VARS['Q3'];
echo "With $HTTP_POST_VARS " . $Q3 . "<BR>";
echo "With $_POST " . $_POST['Q3'] . "<br>";
$Q4 = $HTTP_POST_VARS['Q4'];
echo "With $HTTP_POST_VARS " . $Q4 . "<BR>";
echo "With $_POST " . $_POST['Q4'] . "<br>";
$Q5 = $HTTP_POST_VARS['Q5'];
echo "With $HTTP_POST_VARS " . $Q5 . "<BR>";
echo "With $_POST " . $_POST['Q5'] . "<br>";
$LaborCode = $HTTP_POST_VARS['LaborCode'];
echo "With $HTTP_POST_VARS " . $LaborCode . "<BR>";
echo "With $_POST " . $_POST['LaborCode'] . "<br>";
$Comments = $HTTP_POST_VARS['Comments'];
echo "With $HTTP_POST_VARS " . $Comments . "<BR>";
echo "With $_POST " . $_POST['Comments'] . "<br>";
$HAPPY = $HTTP_POST_VARS['HAPPY'];
echo "With $HTTP_POST_VARS " . $HAPPY . "<BR>";
echo "With $_POST " . $_POST['HAPPY'] . "<br>";
$CLOSEDATE = $HTTP_POST_VARS['CLOSEDATE'];
echo "With $HTTP_POST_VARS " . $CLOSEDATE . "<BR>";
echo "With $_POST " . $_POST['CLOSEDATE'] . "<br>";
mysql_connect("208.185.185.229","a0020386","brumbr50");
mysql_select_db("a0020386");
$query = mysql_query("SELECT RO FROM KEYCAD");
if (mysql_errno()) die(mysql_error());
$row = mysql_fetch_array($query);
$query2 = mysql_query("UPDATE KEYCAD SET CUSTOMERNAME='$CUSTOMERNAME', HOMEPHONE='$HOMEPHONE', BUSPHONE='$BUSPHONE', MODEL='$MODEL', FollowUpContact='$FollowUpContact', CustomerNotReached='$CustomerNotReached', Q1='$Q1', Q2='$Q2', Q3='$Q3', Q4='$Q4', Q5='$Q5', LaborCode='$LaborCode', Comments='$Comments', HAPPY='$HAPPY', CLOSEDATE='$CLOSEDATE' WHERE RO='" . $row["RO"] . "'");
print $query2 . "<br>";
$result2 = mysql_query($query2) or die(mysql_error());
?>
And I am getting this:
With Array 365533
With Array 365533
With Array
With Array
With Array
With Array
With Array
With Array
With Array
With Array
With Array
With Array
With Array
With Array
With Array 0
With Array 0
With Array 0
With Array 0
With Array
With Array
With Array
With Array
With Array
With Array
With Array
With Array
With Array
With Array
With Array
With Array
With Array
With Array
Query was empty