I GOT TROUBLE WITH MSSQL !!!

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
User avatar
farid
Forum Commoner
Posts: 54
Joined: Thu Nov 11, 2004 4:20 pm
Location: Mexico

I GOT TROUBLE WITH MSSQL !!!

Post by farid »

:roll: :cry:

Hi, I hope that someone can help me to execute a query to obtain some information from a stored in a Microsoft SQL server from a different server.

Thanks!![/list]
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

instead of connecting with LOCALHOST use the servers IP addresss. You must also make sure the mysql db is configured to allow from the outside wordl :p
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

post your code
User avatar
farid
Forum Commoner
Posts: 54
Joined: Thu Nov 11, 2004 4:20 pm
Location: Mexico

Post by farid »

Here´s my code:

<?php

$myServer = "192.168.88.4";
$myUser = "estracom";
$myPass = "comerciales";
$myDB = "smsdb";

$conn = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer");

if ($conn) {
mssql_select_db($myDB, $conn) or die("Couldn't open database $myDB");

$stmt=mssql_init("sp_fichasEstrategiasCom",$conn);

$result=mssql_execute($stmt);

$arr=mssql_fetch_row($result);
print ("Answer: " . $arr[0] . "<br>" );

mssql_close($conn);
}
else print("No connection");

?>
And nothing happens!!
=(
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Dump $arr out and see if it is populated. If it isn't than you probably have something wrong with your query. Within the if $conn statement try this:

Code: Select all

<?php
print_r($arr); //or var_dump($arr);
?>
Post Reply