Reputation: 3
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);
Upvotes: 0
Views: 206
Reputation: 990
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
Upvotes: 0
Reputation: 2343
You don't have mssql extension installed. Also you use mssql_query
and mysql_fetch_array
after that. Something wrong here :)
Upvotes: 0
Reputation: 26431
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
Upvotes: 1