queenielow Posted December 14, 2006 Share Posted December 14, 2006 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 ???[code]$username=$_GET['username']; $password=$_GET['pwd']; $dsn="DB03";$sqlconnect=odbc_connect($dsn,$username,$password)or die;$sqlquery="SELECT companyName FROM Customers;";$process=odbc_exec($sqlconnect, $sqlquery);while(odbc_fetch_row($process)){$companyName = odbc_result($process,"companyName");echo "$companyName<br>"; }odbc_close($sqlconnect);[/code]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 Quote Link to comment https://forums.phpfreaks.com/topic/30658-help-i-am-stuck-abt-mssql-and-php/ Share on other sites More sharing options...
Round Posted December 21, 2006 Share Posted December 21, 2006 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 etcif you got it to work in mysql why are you now using an odbc connection?? I have found they can act very differently Quote Link to comment https://forums.phpfreaks.com/topic/30658-help-i-am-stuck-abt-mssql-and-php/#findComment-145758 Share on other sites More sharing options...
The Lost Faith Posted December 25, 2006 Share Posted December 25, 2006 [quote]$username=$_GET['username']; $password=$_GET['pwd']; $dsn="DB03";$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>"; }mysql_close();[/quote]should work Quote Link to comment https://forums.phpfreaks.com/topic/30658-help-i-am-stuck-abt-mssql-and-php/#findComment-147479 Share on other sites More sharing options...
queenielow Posted December 28, 2006 Author Share Posted December 28, 2006 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,town,county,postcode,country,email,emailDPflag,sponsorFlag,paymentRefNo,fundraisingCode,recordType,transQuantity,transCurrency,transAmount,transDate,giftAidFlag,giftAidAmount) values (";for ($i=0; $i<= count($data[$k])-1; $i++) { echo $d="'".trim($data[$k][$i])."',"; }echo "'');"; $sqlquery=odbc_prepare($conn,$insert);$process=odbc_execute($sqlquery) or die; } }[/code]and the output is this :-[quote]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][/quote]Please help me, Thanks alot guys Quote Link to comment https://forums.phpfreaks.com/topic/30658-help-i-am-stuck-abt-mssql-and-php/#findComment-148712 Share on other sites More sharing options...
queenielow Posted December 28, 2006 Author Share Posted December 28, 2006 Hi thanks alot guys..i manage to solve the problem on my own.have a great New Year!Qe Quote Link to comment https://forums.phpfreaks.com/topic/30658-help-i-am-stuck-abt-mssql-and-php/#findComment-148788 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.