hi guys,

I have some error message below:

[FONT="Courier New"]Warning: mssql_query() [function.mssql-query]: Query failed in F:\xampp\htdocs\xl\test1.php on line 289

Fatal error: Call to undefined function mssql_error() in F:\xampp\htdocs\xl\test1.php on line 289
[/FONT]

which is generates from this code snippet:

if($_POST['jakarta_inner']=='a')
{
 echo '<tr><td><font face="Century Gothic"; color="#000099"><strong>MSJ25,CP2</strong></font></td></tr>';
  $rs     = "SELECT DISTINCT * FROM  table1 where  (ne = 'MSJ25,CP2') AND ([day]>='$_POST[date1]' AND [day]<='$_POST[date2]' ) ORDER BY [day] ";
}

  $result = mssql_query($rs) or die(mssql_error());

I really have no idea.. 😕
what should I change from that part to fix the problem??
need your kindly help, guys...
thank's before

    As the PHP error message states, there is no such function called mssql_error(). Perhaps you meant to use [man]mssql_get_last_message/man instead?

      bradgrafelman;10989639 wrote:

      As the PHP error message states, there is no such function called mssql_error(). Perhaps you meant to use [man]mssql_get_last_message/man instead?

      thank u..
      I've already replaced that function as u told me and it goes fine..
      the error message then reduced but it still remains:

      [FONT="Courier New"]Warning: mssql_query() [function.mssql-query]: Query failed in F:\xampp\htdocs\xl\table-jakarta-inner.php on line 289

      Changed database context to 'XL_NPI'.[/FONT]

      as u can see, I found another notification ([FONT="Courier New"]Changed database context to 'XL_NPI'[/FONT]) appears below the previous unsolved error..
      maybe it came from code snippet below, on which the connection to MS SQL server defined..
      but I think it looks no mistakes..

      $con =	mssql_connect("EV0024821A4CA9","username", "password") or die("unnable to connect");
      mssql_select_db("XL_NPI");
      

      CMIIW

        Can you show us what your code looks like now (especially the part where you execute the failing query)?

          bradgrafelman;10989758 wrote:

          Can you show us what your code looks like now (especially the part where you execute the failing query)?

          okay...
          herewith my updated code (plus the sql connection script)

          $con =    mssql_connect("EV0024821A4CA9","username", "password") or die("unnable to connect");
          mssql_select_db("XL_NPI");
          
          
          /* other code here */
          
          
          if($_POST['jakarta_inner']=='a')
          {
          echo '<tr><td><font face="Century Gothic"; color="#000099"><strong>MSJ25,CP2</strong></font></td></tr>';
            $rs     = "SELECT DISTINCT * FROM  table1 where  (ne = 'MSJ25,CP2') AND ([day]>='$_POST[date1]' AND [day]<='$_POST[date2]' ) ORDER BY [day] ";
          }
          
            $result = mssql_query($rs) or die(mssql_get_last_message()); 
          
          
          

            Are you sure the if() branch is even being executed? If it isn't, you'll be trying to execute mysql_query() with an undefined variable.

            Move the call to mysql_query() so that it's inside the if() branch; are you still getting the mssql_get_last_message() output? Also, note you can do a [man]print_r/man (or [man]var_dump/man for even more information) on the entire $_POST array to ensure that your script is receiving the data you expect it to.

            If none of the above reveals anything useful, then I'm afraid I'm out of suggestions (I'm no MSSQL guru).

              9 days later
              bradgrafelman;10989761 wrote:

              Are you sure the if() branch is even being executed? If it isn't, you'll be trying to execute mysql_query() with an undefined variable.

              Move the call to mysql_query() so that it's inside the if() branch; are you still getting the mssql_get_last_message() output? Also, note you can do a [man]print_r/man (or [man]var_dump/man for even more information) on the entire $_POST array to ensure that your script is receiving the data you expect it to.

              If none of the above reveals anything useful, then I'm afraid I'm out of suggestions (I'm no MSSQL guru).

              I have checked the if() branch and finally found the problem there.
              which is the [FONT="Courier New"]"a"[/FONT] value within [FONT="Courier New"]if($_POST['jakarta_inner']=='a')[/FONT] doesn't match with the radiobutten value I've declared before FONT="Courier New"[/FONT]

              thank u so much for your kindly explanations..
              it's all very helpful..
              🙂

                Write a Reply...