Hi i am trying to populate a combobox with info from a table but i get the error:
PHP Fatal error: Call to undefined function mssql_query() in C:\Users\exalell\Desktop\WWW\test\index.php on line 34
This is my index.php:

<?php
  $conn = odbc_connect('fb_intra','',''); 
  // Has the form been submitted?
  if (isset($_POST['item'])) {

// The form has been submitted, query results
$queryitem = "SELECT * FROM Webbyggaren_sidor WHERE sida != ''";

// Successful query?
if($result = mssql_query($queryitem))  {

  // More than 0 results returned?
  if($success = mssql_num_rows($result) > 0) {

    // For each result returned, display it
    while ($row = mssql_fetch_array($result)) echo $row[serial];
  }
  // Otherwise, no results, tell user
  else { echo "No results found."; }
}
// Error connecting? Tell user
else { echo "Failed to connect to database."; }
  }
  // The form has NOT been submitted, so show the form instead of results
  else {

// Create the form, post to the same file
echo "<form method='post' action='index.php'>";

// Form a query to populate the combo-box
$queryitem = "SELECT DISTINCT sida FROM Webbyggaren_sidor;";

// Successful query?                       <------- This is where it all goes wrong.
if($result = mssql_query($queryitem))  {

  // If there are results returned, prepare combo-box
  if($success = mssql_num_rows($result) > 0) {
    // Start combo-box
    echo "<select name='item'>\n";
    echo "<option>-- Select Item --</option>\n";

    // For each item in the results...
    while ($row = mssql_fetch_array($result))
      // Add a new option to the combo-box
      echo "<option value='$row[item]'>$row[item]</option>\n";

    // End the combo-box
    echo "</select>\n";
  }
  // No results found in the database
  else { echo "No results found."; }
}
// Error in the database
else { echo "Failed to connect to database."; }

// Add a submit button to the form
echo "<input type='submit' value='Submit' /></form>";
  }
?>

Do anyone have a clue?

Thanks!

    Have you read the "installation" and "requirements" links?

      Not really sure what you mean, enlighten me 🙂

        The [man]mssql[/man] PHP extension is not installed; you need to install/enable it before you can use the functions in it.

          Write a Reply...