Probably simple PHP & MSSQL query problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
xyligosw
Forum Newbie
Posts: 2
Joined: Thu Sep 15, 2005 3:56 pm

Probably simple PHP & MSSQL query problem

Post by xyligosw »

Hi all, im a bit of a noob at PHP used to do a lot of ASP. I was wondering if anyone could help solve a problem thats plaugeing me:

Code: Select all

$conn = mssql_connect("myhost.com","xyligosw","*****") or die("ERROR: Could not connect to DB!");
		mssql_select_db("xyligo_com",$conn) or die("ERROR: Could Not select Tables!");
		$sql = "SELECT * FROM news";
		echo $conn;
		echo "<br>";
		echo $sql;
$t    = mssql_query($sql,$conn) or die("<br>ERROR");
This executes and leaves me with "ERROR" printed mindlessly without any explanation. I know there is a (or die(mysql_error())) but i can't seem to find one for mssql to give me an accurate idea of whats gone wrong.

All help in this matter is greatly appreciated!!

Thanks

Dan

PS i've removed the hostname and password, these have been checked multiple times and work when used to execute other queries. This seems to be the only one that crashes!
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

this is a long shot, but try putting an @ before mssql_query. i think it would stop the script from stopping or something. i can only remember its exact use vaguely but its definately worth a try. also, give mssql_error a try, might work (would be easier to just check http://www.php.net...)

HTH somehow.
xyligosw
Forum Newbie
Posts: 2
Joined: Thu Sep 15, 2005 3:56 pm

Post by xyligosw »

Thanks,

I tried the @ to no avail, i looked up on php.net, and its mssql_error thats used i used mssql_get_last_message. And that seemed to work, it gave me an understandable error message!

Its not solved but at least i can start to look in the right place.

Thanks again..

Dan
Post Reply