0

Hey guys, So I've been reading all the related topics but they still haven't helped my solve my problem. I am new to php, so any help is greatly appreciated. I am trying to make an array of customers by using a select statement in php but can't connect to the database.

I get this error: Call to undefined function mssql_connect() in script on line 20. Any thoughts? Thanks again!

And the code: $serverName = "*";
$uid = "*";
$pwd = "*";
$databaseName = "
**";

$connectionInfo = array( "User"=>$uid,                              
                        "Password"=>$pwd,                              
                        "Database"=>$databaseName);   

/* Connect using SQL Server Authentication. */    
$conn = mssql_connect($serverName, $connectionInfo);    

$tsql = "SELECT FirstName, LastName, EmailAddr FROM Customer";   

/* Execute the query. */    
$stmt = mssql_query($conn, $tsql);    

if ($stmt)    
{    
    while($row = mysql_fetch_array( $stmt, MSSQL_FETCH_ASSOC))
    {
        $FirstName = $row["FirstName"];
        $LastName = $row["LastName"];
        $EmailAddr = $row["EmailAddr"];
        echo "$FirstName";
        echo "$LastName";
        echo "$EmailAddr";
    }
}     
else     
{    
    echo "Submission unsuccessful.";
    die(print_r( mssql_errors(), true));    
}

/* Free statement and connection resources. */    
mssql_free_stmt($stmt);    
mssql_close($conn);
1
  • 1
    You don't have mssql extension installed. May de you need mYsql_connect()? Commented Apr 22, 2011 at 8:33

3 Answers 3

1

Got configuration and you have to start PHP_Extension

"php_mssql"

If it is wamp got wamp -> php -> PHP extension -> php_mssql

Also php_pdo_mssql

Sign up to request clarification or add additional context in comments.

Comments

0

This error is generating because you have not open MicroSoft SQL server ddl file from php.ini file.

To make this available follow this steps

1) Open your php.ini file 2) search for ;extension=php_mssql.dll 3) uncomment it by removing ";" first 4) Restart your server

Regards

Comments

0

You don't have mssql extension installed. Also you use mssql_query and mysql_fetch_array after that. Something wrong here :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.