Jump to content

Help. I am stuck abt MSSQL and PHP


Recommended Posts

Hi All,

I need some guideline on this error.
I dont have any idea how can i connect properly using PHP n MSSQL. I tried all methods.
I have set up the Data Source ( system and User)

The problem is i dont want it to connect to [b]'RELIEF\FRB4340GFX$'[/b] username- because its invalid. here are my script.
Is there any way i can tell the system to login using $username instead of fetching it automatically.

sorry ( i am totally new with MSSQL), i've done the duplicate in MYSQL- which works FINE. But i need it works in MSSQL.

Thanks alot for any helps.
Qe  ???



$sqlconnect=odbc_connect($dsn,$username,$password)or die;
$sqlquery="SELECT companyName FROM Customers;";
$process=odbc_exec($sqlconnect, $sqlquery);

$companyName = odbc_result($process,"companyName");
echo "$companyName<br>";

Error message:-
Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'RELIEF\FRB4340GFX$'., SQL state 28000 in SQLConnect in C:\wamp\www\CR_www\sqlserver.php on line 23
Link to comment
Share on other sites

This may be wrong.

Why dont you use the same code as the mysql connection and just change it from mysql_connect to mssql_connect etc etc

if you got it to work in mysql why are you now using an odbc connection?? I have found they can act very differently
Link to comment
Share on other sites



$sqlconnect= mssql_connect($dsn,$username,$password)or die;
$sqlquery="SELECT companyName FROM Customers;";
$process= mssql_query($sqlconnect, $sqlquery);

while($row = mssql_fetch_array($process)){
echo $row['companyName']."<br>";

should work
Link to comment
Share on other sites

HI Both ,

Thanks alot.. It's work.. My stupidity that thought the function is working in this way.
But now i got another problem. which i dont know what's went wrong.

this is my code.
[code]include 'sqlconnect.php';
$data = file("conv1.csv");
$result = count($data);

for ($i=0;$i<=$result-1;$i++){

while (list($k,$v)=each($data)) {
  $data[$k] = explode(',', $v);
echo  $insert="insert into queenie.test (dataSource,dataSourceRef,multiplierUrn,prefix,firstName,middleName,lastName,address1,address2,address3
transQuantity,transCurrency,transAmount,transDate,giftAidFlag,giftAidAmount) values (";
for ($i=0; $i<= count($data[$k])-1; $i++) {
echo $d="'".trim($data[$k][$i])."',";
echo "'');";
$process=odbc_execute($sqlquery) or die;

and the output is this :-
insert into queenie.test (dataSource,dataSourceRef,multiplierUrn,prefix,firstName,middleName,lastName,address1,address2,address3,town,county,postcode,country,email,emailDPflag,sponsorFlag,paymentRefNo,fundraisingCode,recordType,transQuantity,transCurrency,transAmount,transDate,giftAidFlag,giftAidAmount) values ('WORLDPAY','182005289','8005220','Ms','Queenie','Low','Low','London','0','0','London','0','NW6 4NA','GB','queenie.low@gmail.com','1','0','182005289','87','1109','1','GBP','1','04/07/2006 09:11:28','1','');

[color=red][font=Verdana]Warning: odbc_execute() [function.odbc-execute]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '('., SQL state 37000 in SQLExecute in C:\wamp\www\CR_www\sql-format.php on line 18[/font][/color]

Please help me,

Thanks alot guys
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.