Reputation: 16851
I have connected to MSSQL, but i am unaware to do a select statement and print it out. I have done this using MySQL, but unable to convert it to MSSQL. Can someone help me to find the equvalent for mysql_query
,mysql_real_escape_string
,mysql_num_rows
,mysql_fetch_array
or a sample code that helps.
// Connecting to MSSQL - Working
$name = $_POST['myname'];
$x=mysql_query("SELECT * FROM MyTable WHERE Name='".mysql_real_escape_string($name)."'");
$num_rows = mysql_num_rows($x);
while($norows = mysql_fetch_array($x)) {
// PRINT ROW
}
Upvotes: 4
Views: 201
Reputation: 72646
In MSSQL there are the following alternative functions :
mysql_query ---> mssql_query
mysql_num_rows ---> mssql_num_rows
mysql_fetch_array ---> mssql_fetch_array
Take a look at the official documentation here for more information ...
The only missing function is the escape string(mysql_real_escape_string
), for that purpose you can define yourself a function like this one :
function mssql_escape($str) {
if(get_magic_quotes_gpc())
{
$str= stripslashes($str);
}
return str_replace("'", "''", $str);
}
Upvotes: 3