query error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • geraldjr30
    New Member
    • Jan 2009
    • 60

    #1

    query error

    hi,

    i have the following:

    Code:
    <form method="post" action="<?php echo $PHP_SELF;?>">
    <span style='color: #008b8b; font-size: 10pt; font-family: arial'>
    &nbsp &nbsp <b>search </b><input type="number" size="24" class = "INPUTWHITE" maxlength="20" name="SEARCH" value="<?php echo $_POST['search'];?>"
    </span>
    <input type="submit" value=">" name="submit" class = "btn"></form>
    
    
    $SEARCH = $_POST["SEARCH"];
    
    $sql="SELECT [account number] AS acct, month, code, age, [time] AS TM FROM table_name WHERE GRP = '".$GRP."' AND acct= '".$SEARCH."' AND day ='".$count."'";
    I have checked the table to make sure the [account number] is a number type. i am getting an error message like:

    "Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1., SQL state 07001 in SQLExecDirect in C:\Program Files\Apache Software ..."

    not sure what to do...

    thanks in advance,
    geebee
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Can we see the part that uses odbc_exec() please.

    Comment

    • geraldjr30
      New Member
      • Jan 2009
      • 60

      #3
      hi,
      here is the whole thing...

      Code:
      <html>
      
      
      <STYLE type="text/css">
      		TD{font-family:ARIAL;font-size:12px;color:#666666;}
      		BODY{font-family:ARIAL;font-size:11px;color:#666666;background-color:#ffffff;margin-top:40px;margin-bottom:0px;margin-left:40px;margin-right:0px;}
      		FORM{display:inline;}	
      		A:LINK, A:VISITED{color:#6699cc;text-decoration:none;}
      		A:HOVER{text-decoration:underline;color:#CCCCCC;}
      		.HOMETEXT{font-size:14px;}
      		.ITEMNAME{font-size:14px;font-weight:BOLD;}
      		/*.WHITELINK{color:#ffffff;font-size:10px;}*/
      		.INPUT{border-color:#66CCFF;border-width:1px;border-style:solid;background-color:#eeeeee;font-size:10px;}
      		.INPUTWHITE{border-color:#66CCFF;border-width:1px;border-style:solid;background-color:#ffffff;font-size:10px;}
      		.INPUT2{background-image:url(webtd_grass_matrix_pic4.jpg);color:#666666;border-top:1px solid #BBBBBB;border-bottom:1px solid #BBBBBB;border-right:1px solid #BBBBBB; border-left:1px solid #BBBBBB; font-family:copperplate gothic light;font-size:7pt;}
      		.BUTTON{border-color:#99CCFF;border-width:1px;border-style:solid;}
      		.BOLD{color:#666666;font-family:Arial, Tahoma, Helvetica, sans-serif;font-size:8pt;font-weight:BOLD;}
      		.BOLDLARGE{color:#666666;font-size:12pt;font-weight:BOLD;}
      		.CURRENTPAGE{color:#666666;font-size:8pt;font-weight:BOLD;}
      		.ERROR{color:#cc0033;font-size:8pt;font-weight:BOLD;}
      		.MENUCELL{height:24px;width:80px;text-align:center;font-weight:BOLD;color:#FFFFFF;border-top:1px solid #BBBBBB;border-bottom:1px solid #BBBBBB;border-right:1px solid #BBBBBB;}
      		.MENUCELLSTART{height:24px;width:80px;border:1px solid #BBBBBB;text-align:center;font-weight:BOLD;color:#FFFFFF;}
      		.SPACE1{padding-left:20px;}
      		.BORDER{background-color:#EEEEEE;color:#666666;border-top:1px solid #BBBBBB;border-left:1px solid #BBBBBB;border-bottom:1px solid #BBBBBB;border-right:1px solid #BBBBBB;height:24px;padding-left:16px;}
      		.IVORYBG{background-color:#FFFFF0;color:#EEE8AA;border-top:1px solid #EEE8AA;border-left:1px solid #EEE8AA;border-bottom:1px solid #EEE8AA;border-right:1px solid #EEE8AA;height:24px;padding-left:16px;}
      		.BORDER1{border-bottom:1px solid #BBBBBB;}
      		.BORDER2{background-color:#EEEEEE;color:#666666;border:1px solid #BBBBBB;}
      		.BORDER3{background-color:#000000;color:#666666;border-top:1px solid #ffffff;border-bottom:1px solid #ffffff;border-right:1px solid #ffffff;height:44px;padding-left:16px;}
      		.HEADER{background-color:#EEEEEE;color:#666666;border:1px solid #BBBBBB;height:24px;font-weight:BOLD;padding-left:20px;}
      		.PRODCELL{border-left:1px solid #BBBBBB;border-bottom:1px solid #BBBBBB;background-color:#FFFFFF;}
      		.HEADER1{background-color:#EEEEEE;color:#666666;border-left:1px solid #BBBBBB;border-top:1px solid #BBBBBB;border-bottom:1px solid #BBBBBB;height:24px;font-weight:BOLD;padding-left:20px;}
      		.HEADER5{width:130px;color:#666666;background-color:#EEEEEE;border-top:1px solid #BBBBBB;border-right:1px solid #BBBBBB;height:24px;}
      		.PRODIMGLGCELL{width:300px;height:295px;background-color:#EEEEEE;border-left:1px solid #BBBBBB;border-right:1px solid #BBBBBB;border-bottom:1px solid #BBBBBB;vertical-align:top;text-align:center;}
      		.PRODIMGSMCELL{width:130px;height:125px;background-color:#EEEEEE;border-left:1px solid #BBBBBB;border-right:1px solid #BBBBBB;border-bottom:1px solid #BBBBBB;vertical-align:top;text-align:center;}
      		.PRODIMGSM{border:1px solid white;height:120px;width:120px;align:middle;}
      		.PRODIMGLG{border:1px solid #BBBBBB;height:290px;width:290px;align:middle;}
      		.CATIMG{width:120px;height:120px;border:1px solid #BBBBBB;}
      		.stylegreyblue {color: #669999}
      		.stylelightblue {color: ##DEE7F7}
      		.styleblack {color:#000000}
      		.stylegreyblack {color:#444444}
      		.styledarkpink {color: #990033}
      		.styleslateblue {color: #008b8b}
      		.stylewhite {color: #ffffff}
      		.input.btn {color:#666666; font: bold small 'trebuchet ms',helvetica,sans-serif; 
      		background-color: #eeeeee;
      		border:1px solid;   
      		border-color: #66CCFF #66CCFF #66CCFF #66CCFF; 
      		font-size:11px; 
      		}  
      
      //a { 
      //    position: right; 
      //   top: 5pt ; 
      //    left: 10pt ; 
      //} 
      
      //a2 { 
      //    position: left; 
      //    top: 80pt ; 
      //    left: 80pt ; 
      //} 
      
      
      .style17 {color: #666666}
      .style18 {color: #CC6699}
      .style19 {color: #CCCCCC}
      .style22 {font-family: Verdana; color: #CCCCCC;}
      .style23 {color: #66CCFF}
      .style24 {
      	color: #99FF66;
      	font-weight: bold;
      }
      .style26 {color: #99FF66}
      .style27 {color: #999999}
      .stylered {color: #FF0000}
      .stylegreen {color: #00FF00}
      
      </STYLE>
       
      
      
      <SCRIPT LANGUAGE="text/JavaScript">
         function FRESHEN() 
       { 
         window.location.reload();
      }
      </SCRIPT>
      
      
      
      <SCRIPT LANGUAGE="text/JavaScript">
         function go_back_1() 
       { 
         history.go(-1); 
      }
      </SCRIPT>
      
      
      
      <SCRIPT LANGUAGE="text/JavaScript">
         function go_back_2() 
       { 
        history.go(-2); 
      }
      </SCRIPT>
      
      
      
      
      <SCRIPT LANGUAGE="text/JavaScript"> 
      function showLoc2() 
      var a = document.getElementById("link"); 
      a.addEventListener("click", go_back_1, false); 
      if (window.location.hash == "#top") 
      { 
          a.firstChild.nodeValue = "TWO"; 
          a.removeEventListener("click", go_back_1, false); 
          a.addEventListener("click", go_back_2, false); 
      } 
      </SCRIPT>
      
      
      </head>
      
      
      
      <!---
      <BODY onload = "TOOT();">
      -->
      <BODY>
      
      
      
      
      
      <!---
      <a href  "#" onclick = "go_back_1" id="link">ONE</a>  
      
      <a href onclick = "go_back_1(this.href);return false" id="link">ONE</a> 
      -->
      
      
      
      <?php
      $count=$_GET['count'];
      $fac= strtoupper($_GET['fac']);
      $SRG_GROUP=$_GET['SRG_GROUP'];
      $SFT=$_GET['SFT'];
      ?>
      
      
      
      
      
      <br>
      
      <table width = "300" height = "10" align = "left" border = "0" class = "border">
      <tr>
      <td>
      <form method="post" name = "searchFORM" action="<?php echo $PHP_SELF;?>">
      <span style='color: #008b8b; font-size: 10pt; font-family: arial'>
      &nbsp &nbsp <b>search </b><input type="number" size="24" class = "INPUTWHITE" maxlength="20" name="SEARCH" value="<?php echo $_POST['search'];?>"
      </span>
      <!---
      <input type="submit" value=">" name="submit" class = "btn">
      -->
      &nbsp &nbsp 
      <b>
      <a href="#" onclick="javascript:document.forms.searchFORM.submit();">go</a>
      </b>
      </form>
      <br>
      </td>
      </tr>
      </table>
      
      <br>
      <br>
      <br>
      
      
      
      <?php
      
      #echo $_SERVER['REQUEST_URI']
      #echo "<a href = 'COUNTTEST.php'>HOME</a><br><br>";
      
      
      
      
      echo "<a name=top></a><br>";
      
      echo "<A HREF='javascript:javascript:history.go(-1)'>HOME</A><br><br>";
      
      $SEARCH = $_POST["SEARCH"];
      
      
      
      
      
      
      
      echo "<div align = 'right'><SCRIPT LANGUAGE='JavaScript'>";
      echo "   function TOOT() ";
      echo " { ";
      echo "   var x = window.location.hash; ";
      echo "if (x == '#top')"; 
      echo "{ ";
      echo "document.body.innerHTML += '<a href=\'javascript:javascript:history.go(-2)\'>BACK </a>';";
      echo "}";
      echo "else";
      echo "{";
      echo "document.body.innerHTML += '<a href=\'javascript:javascript:history.go(-1)\'>BACK</a>';";
      echo "}";
      echo "}";
      echo "</SCRIPT></div>";
      
      
      
      print "<span style='color: #008b8b; font-size: 20pt; font-family: arial'><b>";
      
      echo $count;
      echo "<br>";
      print "</b></span>";
      print "<span class='style17'><font face = 'arial' size = '1'>";
      
      if(isset($_GET['SFT'])) 
      {
      echo "<span style='color: #666666; font-size: 8pt; font-family: arial'>$_GET[SFT]</span><br><br>";
      }
      else
      {
      echo "<span style='color: #666666; font-size: 8pt; font-family: arial'>all shifts</span><br><br>";
      }
      
      
      
      echo $fac;
      echo "<br>";
      echo $SRG_GROUP;
      echo "<br><br>";
      print "</font></span>";
      
      
      #!empty checks if the variable is NOT empty
      #if(empty($_GET['SFT']) AND empty($_GET['fac']))
      #{
      #echo "one";
      #}
      #elseif(empty($_GET['SFT']) AND !empty($_GET['fac'])) 
      #{
      #echo "two";
      #}
      #elseif(isset($_GET['SFT']) AND empty($_GET['fac']))
      #{
      #echo "three";
      #}
      #else
      #{
      #echo "four";
      #}
      
      
      
      $conn=odbc_connect('ERVOLUMES','','');
      if (!$conn)
        {exit("Connection Failed: " . $conn);}
      
      #if(isset($_GET['SFT']))
      
      #if(empty($_GET['SFT']) AND empty($_GET['fac']))
      #{
      #$sql="SELECT [patient account number] AS patient_account_number, dischargeday, hospitalcode, age, [discharge time] AS discharge_time FROM 1_shift WHERE SRG_GROUP = '".$SRG_GROUP."' AND admitday ='".$count."'";
      #}
      #elseif(empty($_GET['SFT']) AND isset($_GET['fac']))
      #{
      #$sql="SELECT [patient account number] AS patient_account_number, dischargeday, hospitalcode, age, [discharge time] AS discharge_time FROM 1_shift WHERE SRG_GROUP = '".$SRG_GROUP."' AND hospitalcode LIKE '".$fac."' AND admitday ='".$count."'";
      #}
      #else
      #{
      #$sql="SELECT [patient account number] AS patient_account_number, dischargeday, hospitalcode, age, admit_shift, [discharge time] AS discharge_time FROM 1_shift WHERE SRG_GROUP = '".$SRG_GROUP."' AND admit_shift = '".$_GET['SFT']."' AND  admitday ='".$count."'";
      #}
      
      
      
      
      if(empty($_POST['SEARCH']))
      {
      if(empty($_GET['SFT']) AND empty($_GET['fac']))
      {
      $sql="SELECT [patient account number] AS patient_account_number, dischargeday, hospitalcode, age, [discharge time] AS discharge_time FROM 1_shift WHERE SRG_GROUP = '".$SRG_GROUP."' AND admitday ='".$count."'";
      }
      elseif(empty($_GET['SFT']) AND !empty($_GET['fac'])) 
      {
      $sql="SELECT [patient account number] AS patient_account_number, dischargeday, hospitalcode, age, [discharge time] AS discharge_time FROM 1_shift WHERE SRG_GROUP = '".$SRG_GROUP."' AND hospitalcode LIKE '".$fac."' AND admitday ='".$count."'";
      }
      elseif(isset($_GET['SFT']) AND empty($_GET['fac']))
      {
      $sql="SELECT [patient account number] AS patient_account_number, dischargeday, hospitalcode, age, admit_shift, [discharge time] AS discharge_time FROM 1_shift WHERE SRG_GROUP = '".$SRG_GROUP."' AND admit_shift = '".$_GET['SFT']."' AND  admitday ='".$count."'";
      }
      else
      {
      $sql="SELECT [patient account number] AS patient_account_number, dischargeday, hospitalcode, age, admit_shift, [discharge time] AS discharge_time FROM 1_shift WHERE SRG_GROUP = '".$SRG_GROUP."' AND admit_shift = '".$_GET['SFT']."' AND hospitalcode LIKE '".$fac."' AND  admitday ='".$count."'";
      }
      }
      
      
      
      
      if(!empty($_POST['SEARCH']))
      {
      if(empty($_GET['SFT']) AND empty($_GET['fac']))
      {
      $sql="SELECT [patient account number] AS patient_account_number, dischargeday, hospitalcode, age, [discharge time] AS discharge_time FROM 1_shift WHERE SRG_GROUP = '".$SRG_GROUP."' AND patient_account_number = '12686900' AND admitday ='".$count."'";
      }
      elseif(empty($_GET['SFT']) AND !empty($_GET['fac'])) 
      {
      $sql="SELECT [patient account number] AS patient_account_number, dischargeday, hospitalcode, age, [discharge time] AS discharge_time FROM 1_shift WHERE SRG_GROUP = '".$SRG_GROUP."' AND hospitalcode LIKE '".$fac."' AND patient_account_number = '12686900' AND admitday ='".$count."'";
      }
      elseif(isset($_GET['SFT']) AND empty($_GET['fac']))
      {
      $sql="SELECT [patient account number] AS patient_account_number, dischargeday, hospitalcode, age, admit_shift, [discharge time] AS discharge_time FROM 1_shift WHERE SRG_GROUP = '".$SRG_GROUP."' AND admit_shift = '".$_GET['SFT']."' AND patient_account_number = '12686900' AND  admitday ='".$count."'";
      }
      else
      {
      $sql="SELECT [patient account number] AS patient_account_number, dischargeday, hospitalcode, age, admit_shift, [discharge time] AS discharge_time FROM 1_shift WHERE SRG_GROUP = '".$SRG_GROUP."' AND admit_shift = '".$_GET['SFT']."' AND hospitalcode LIKE '".$fac."' AND patient_account_number = '12686900' AND  admitday ='".$count."'";
      }
      }
      
      
      
      if(!empty($_POST['SEARCH']))
      {
      print "<span style='color: #008b8b; font-size: 12pt; font-family: arial'><b>";
      echo "search results for:";
      print "&nbsp";
      echo $SEARCH;
      print "</b></span>";
      }
      
      
      
      
      $rs=odbc_exec($conn,$sql);
      
      
      
      print "<hr size = 1 width = 400 align = left color = #666666>";
      print "<span style='color: #008b8b; font-size: 10pt; font-family: arial'><b>";
      echo "details <br>";
      print "</b></span>";
      
      
      echo "<br><table width = '500' height = '10' align = 'left' border = '0'>";
      echo "<tr height = '10'>";
      echo "<td width = '100' height = '10'><b>ADMIT DAY</b></td>";
      echo "<td width = '100' height = '10'><b>AGE</b></td>";
      echo "<td width = '100' height = '10'><b>DISCH DAY</b></td>";
      echo "<td width = '100' height = '10'><b>PT ACCT#</b></td>";
      echo "<td width = '100' height = '10'><b>DISCH TIME</b></td>";
      echo "</tr>";
      echo "</table><br>";
      
      echo "<br><table width = '500' height = '10' align = 'left' border = '0'>";
      
      
      if (!$rs)
        {exit("Error in SQL");}
      while (odbc_fetch_row($rs))
      {
       
      
        $DISDAY=odbc_result($rs, dischargeday);
        $AGE=odbc_result($rs, age);
        $PTACCTNO=odbc_result($rs, patient_account_number);
        $DISCHTIME=odbc_result($rs, discharge_time);
      
      
      
      echo "<tr height = '10'>";
      echo "<td width = '100' height = '10'>$count</td>";
      echo "<td width = '100' height = '10'>$AGE</td>";
      echo "<td width = '100' height = '10'>$DISDAY</td>";
      echo "<td width = '100' height = '10'>$PTACCTNO</td>";
      echo "<td width = '100' height = '10'>$DISCHTIME</td>";
      echo "</tr>";
      
      
      
      
      #echo $count;
      #echo "&nbsp &nbsp $AGE &nbsp $DISDAY &nbsp $PTACCTNO &nbsp $DISCHTIME<br>";
      
      
      }
      
      
      
      echo "<tr height = '10'>";
      #echo "<td width = '100' height = '10'><br><a href='#top' onClick='window.location.reload( true );'>back to top</a></td>";
      echo "<td width = '100' height = '10'><br></td>";
      echo "<td width = '100' height = '10'>";
      
      
      
      echo "<div align = 'right'><SCRIPT LANGUAGE='JavaScript'>";
      echo "   function showLoc() ";
      echo " { ";
      echo "   var x = window.location.hash; ";
      echo "if (x == '#top')"; 
      echo "{ ";
      echo "document.body.innerHTML += '<a href=\'javascript:javascript:history.go(-2)\'>TWO </a>';";
      echo "}";
      echo "else";
      echo "{";
      echo "document.body.innerHTML += '<a href=\'javascript:javascript:history.go(-1)\'>ONE</a>';";
      echo "}";
      echo "}";
      echo "</SCRIPT></div>";
      
      
      echo "</td>";
      echo "<td width = '100' height = '10'></td>";
      echo "<td width = '100' height = '10'></td>";
      echo "<td width = '100' height = '10'><b></td><br>";
      echo "</tr>";
      
      
      echo "</table><br><br><br>";
      
      
      
      
      
      
      ?>
      
      
      
      
      
      
      
      
      
      
      
      
      
      </html>

      error pointing to line 345

      Comment

      • nathj
        Recognized Expert Contributor
        • May 2007
        • 937

        #4
        While we wait <-- post must have crossed in the ether, for the requested code I thought I should pass on some experience I had recently.

        I bought a CMS (don't ask why, I should have built the site myself) that used Access as the DB. This was a disaster. Running Access over the web - as I assume you are given that this is a PHP forum - Access can't handle concurrent usage that the web requires.

        The only solution was for me to convert the DB to MySQL and now it works a treat. I say a treat there are other issues relating to coding standards but that's another issue.

        My word of advice is if your system is web based or needs many users accessing the data at the same time then switch from Access to MySQL or SQL Server now and save yourself from a world of pain.

        There you have it, I hope that was helpful.

        I should say that you can easily switch the database over using Bullzip converter as I did but beware of special characters.

        Cheers
        nathj

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          Don't need to see the whole thing; just the parts that relate to the query and the error given. Thanks.

          Also, outputting all that html is really very unhealthy. Have a look at the Heredoc syntax.

          Comment

          • geraldjr30
            New Member
            • Jan 2009
            • 60

            #6
            i really think it has something to do with the line 163... not matching up with the correct datatype... or some quotes or something missing in the query string. but im not sure how to fix this.

            Comment

            Working...