You are here: mssql_query not returning « PHP Programming Language « IT news, forums, messages
mssql_query not returning

Posted by Lado.Leskovec on 09/11/07 09:14

HI!

I have been using MySQL in connection with PHP for fun for several
years now, but at work they recently wanted me to develop an
application, that uses MS SQL server 2005.

I managed to overcome several problems and can now connect to server
and to database, but the mssql_query isnt returning anything.

Code I use:
************************************************************************
$connection= mssql_connect($server, $username, $password)
or die("Couldn't connect to SQL Server on $server");

//select a database to work with
$DB = mssql_select_db($database, $connection)
or die("Couldn't open database $database");

$result=mssql_query("SELECT * FROM Persons")
or die("Couldn't create a result.");

mssql_close($connection);

$num_user=mssql_num_rows($result);

$i=$num_user;

while ($i > 0)
{
$Name=mssql_result($result,$i-1,"Name");
echo "$Name<br>";
$i--;
}
************************************************************************

I tried this SQL query from MS SQL Server Management Studio and it
works fine. I get my desired result there. I also tried to supply the
$connection after the SQL statement.

I also tried to remove the "or die("Couldn't create a result.");"
part, which continues the program, but the $result is empty.

What am I doing wrong?

Thanks in advance!
Lado

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация