View Full Version : PHP + MS SQL Server...

10-31-2003, 04:19 PM

I'm working now with PHP + Microsoft SQL Server, but it's kind of easy, because the functions are much like the mysql ones.

Anyway, I have now a problem. I have a query like this:

SELECT * FROM client ORDER BY client_name

Everything goes right in the MS SQL Query Analyzer, it returns me ALL rows and fields from that table, but when i do it in php, it seems that the '*' wildcard doesn't work...

//In mysql I use either mysql_fetch_array , mysql_fetch object or mysql_fetch_row
$query_clients="SELECT id_cli,client FROM client WHERE client LIKE 'g%' ORDER BY client";
echo "<br />Error. ".mssql_get_last_message()."<br />";
echo "<option value='".$obj->id_cli."'>".htmlentities($obj->client)."</option>\n";

As you see, I'm filling a select item with the query results and everything goes right, but when I do the same with the '*', it returns the select item like this...

<select name="select_client">
<option value="--">SELECT A CLIENT</option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<!--It repeats the line 'msssql_rows_affected' times-->

I can do this by only selecting the fields that I need, but my doubt is, why does '*' not work???