Jump to content

What am I doing wrong?!!?


Shamrox

Recommended Posts

Ok, this seems like it would be straight forward, but I keep getting "Query is empty" output on my page after I submit the form. Could someone please tell me WTH I'm doing wrong here???  Below is the entire page that is used as an include in the main page template.


[code]
<?php require_once('../Connections/spectrum.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;   
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_spectrum, $spectrum);
$query_rs_client = "SELECT clientid, name FROM spec_client ORDER BY name ASC";
$rs_client = mysql_query($query_rs_client, $spectrum) or die(mysql_error());
$row_rs_client = mysql_fetch_assoc($rs_client);
$totalRows_rs_client = mysql_num_rows($rs_client);



if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

$colname_rs_output = "-1";
if (isset($_GET['clientid'])) {
  $colname_rs_output = (get_magic_quotes_gpc()) ? $_GET['clientid'] : addslashes($_GET['clientid']);
}
$colname_rs_output = "-1";
if (isset($_GET['orderdateA'])) {
  $colname_rs_output = (get_magic_quotes_gpc()) ? $_GET['orderdateA'] : addslashes($_GET['orderdateA']);
}
$colname_rs_output = "-1";
if (isset($_GET['orderdateB'])) {
  $colname_rs_output = (get_magic_quotes_gpc()) ? $_GET['orderdateB'] : addslashes($_GET['orderdateB']);
}
mysql_select_db($database_spectrum, $spectrum);
$query_rs_output = sprintf("SELECT `spec_course`.`ctitle`, `spec_course`.`course_num`, `spec_client`.`name`,
`spec_contacts`.`lastname`, `spec_contacts`.`firstname`,
DATE_FORMAT(`spec_registrar`.`orderdate`,'%c/%e/%Y') AS `orderdate1`,
DATE_FORMAT(`spec_registrar`.`enddate`, '%c/%e/%Y') AS `enddate1`,
DATE_FORMAT(`spec_registrar`.`startdate`, '%c/%e/%Y') AS `startdate1`,
`spec_registrar`.*
FROM `spec_registrar`
INNER JOIN `spec_students` ON `spec_registrar`.`studentid` = `spec_students`.`studentid`
INNER JOIN `spec_client` ON `spec_client`.`clientid` = `spec_students`.`clientid`
INNER JOIN `spec_client` ON `spec_client`.`clientid` = `spec_registrar`.`clientid`
INNER JOIN `spec_contacts` ON `spec_contacts`.`contactid` = `spec_students`.`contactid`
WHERE `spec_registrar`.`clientid` = %s AND `spec_registrar`.`orderdate` BETWEEN %s AND %s", GetSQLValueString($colname_rs_output, "int"),GetSQLValueString($colname_rs_output, "date"),GetSQLValueString($colname_rs_output, "date"));
$rs_output = mysql_query($query_rs_output, $spectrum) or die(mysql_error());
$row_rs_output = mysql_fetch_assoc($rs_output);
$totalRows_rs_output = mysql_num_rows($rs_output);
}
?>

<form id="form1" name="form1" method="post" action="<?php echo $editFormAction; ?>">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="29%">Select Client:
        <select name="select">
          <?php
do { 
?>
          <option value="<?php echo $row_rs_client['clientid']?>"><?php echo $row_rs_client['name']?></option>
          <?php
} while ($row_rs_client = mysql_fetch_assoc($rs_client));
  $rows = mysql_num_rows($rs_client);
  if($rows > 0) {
      mysql_data_seek($rs_client, 0);
  $row_rs_client = mysql_fetch_assoc($rs_client);
  }
?>
        </select>
</td>
      <td width="16%"><input name="orderdateA" type="text" id="orderdateA" /></td>
      <td width="55%"><input name="orderdateB" type="text" id="orderdateB" /><input type="hidden" name="MM_insert" value="form1"> <input type="submit" name="Submit" value="Submit" /></td>
    </tr>
  </table>
</form>

<!--Output the table starting here -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th scope="col">Order Date </th>
    <th scope="col">Student Lastame, First </th>
    <th scope="col">Course ID </th>
    <th scope="col">Course Title </th>
    <th scope="col">Training Co </th>
    <th scope="col">Course Start date </th>
    <th scope="col">Course End date </th>
    <th scope="col">Course Length </th>
    <th scope="col">Purchase Order </th>
    <th scope="col">Cost Center </th>
    <th scope="col">List Price </th>
    <th scope="col">Sales Price </th>
    <th scope="col">Status</th>
  </tr>
  <tr>
    <td><? echo $row_rs_output['orderdate1']; ?></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<?php
mysql_free_result($rs_client);

mysql_free_result($rs_output);

?>
[\code][/code]
Link to comment
https://forums.phpfreaks.com/topic/31925-what-am-i-doing-wrong/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.