zduchene Posted January 24, 2008 Share Posted January 24, 2008 I need the help of the form. I am using PHP and connecting to MSSQL database . I wrote a MSSQL query and tested it on the MSSQL Query Analyzer program where it worked great, did exactly what I wanted it to. I integrated the query into a php script and I am getting: PHP Warning: mssql_query() [function.mssql-query]: message: Line 1: Incorrect syntax near '.'. (severity 15) in C:\webapps\htdocs\ji\ji2.php on line 7 PHP Warning: mssql_query() [function.mssql-query]: Query failed in C:\webapps\htdocs\ji\ji2.php on line 7 Here is the php script along with the query: $q = 'SELECT "estimate"."job number", "DEBTOR"."NAMES", "ESTIMATE"."details1", "debtor"."salesrep", "salesrep"."name" AS "csr", "estimate"."due date", "estimate"."order no", "estimate"."qty1", "estimate"."qty2", "estimate"."qty3", "estimate"."qty4" FROM "LIVEDATA_Dosrun"."dbo"."ESTIMATE", "LIVEDATA_Dosrun"."dbo"."DEBTOR", "LIVEDATA_Dosrun"."dbo"."SALESREP", "LIVEDATA_Dosrun"."dbo"."INVOICE" WHERE "ESTIMATE"."JOB NUMBER" = 53373 AND "INVOICE"."JOB NO" = "ESTIMATE"."JOB NUMBER" AND "INVOICE"."CSR RECNUM" = "SALESREP"."DATAFLEX RECNUM ONE" AND "DEBTOR"."AC NO" = "ESTIMATE"."DEBTOR"'; $result = mssql_query($q); Any help is appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/87595-php-mssql-help/ Share on other sites More sharing options...
jorgep Posted January 24, 2008 Share Posted January 24, 2008 I can't think of something right now, I've never worked with MSSQL before, but would it work if you remove the double quotes (")?. Or try replacing them (") with this (`). Let us know! Quote Link to comment https://forums.phpfreaks.com/topic/87595-php-mssql-help/#findComment-448038 Share on other sites More sharing options...
zduchene Posted January 24, 2008 Author Share Posted January 24, 2008 new error: PHP Warning: mssql_query() [function.mssql-query]: message: Line 1: Incorrect syntax near '`'. (severity 15) in C:\webapps\htdocs\ji\ji2.php on line 7 PHP Warning: mssql_query() [function.mssql-query]: message: Unclosed quotation mark before the character string ''. (severity 15) in C:\webapps\htdocs\ji\ji2.php on line 7 PHP Warning: mssql_query() [function.mssql-query]: Query failed in C:\webapps\htdocs\ji\ji2.php on line 7 Quote Link to comment https://forums.phpfreaks.com/topic/87595-php-mssql-help/#findComment-448051 Share on other sites More sharing options...
jorgep Posted January 24, 2008 Share Posted January 24, 2008 It will be read better if you write it like this: SELECT "estimate"."job number", "DEBTOR"."NAMES", "ESTIMATE"."details1", "debtor"."salesrep", "salesrep"."name" AS "csr", "estimate"."due date", "estimate"."order no", "estimate"."qty1", "estimate"."qty2", "estimate"."qty3", "estimate"."qty4" FROM "LIVEDATA_Dosrun"."dbo"."ESTIMATE", "LIVEDATA_Dosrun"."dbo"."DEBTOR", "LIVEDATA_Dosrun"."dbo"."SALESREP", "LIVEDATA_Dosrun"."dbo"."INVOICE" WHERE "ESTIMATE"."JOB NUMBER" = 53373 AND "INVOICE"."JOB NO" = "ESTIMATE"."JOB NUMBER" AND "INVOICE"."CSR RECNUM" = "SALESREP"."DATAFLEX RECNUM ONE" AND "DEBTOR"."AC NO" = "ESTIMATE"."DEBTOR" Quote Link to comment https://forums.phpfreaks.com/topic/87595-php-mssql-help/#findComment-448058 Share on other sites More sharing options...
revraz Posted January 24, 2008 Share Posted January 24, 2008 $q = "SELECT estimate.job number, DEBTOR.NAMES, ESTIMATE.details1, debtor.salesrep, salesrep.name AS csr, estimate.due date, estimate.order no, estimate.qty1, estimate.qty2, estimate.qty3, estimate.qty4 FROM LIVEDATA_Dosrun.dbo.ESTIMATE, LIVEDATA_Dosrun.dbo.DEBTOR, LIVEDATA_Dosrun.dbo.SALESREP, LIVEDATA_Dosrun.dbo.INVOICE WHERE ESTIMATE.JOB NUMBER = 53373 AND INVOICE.JOB NO = ESTIMATE.JOB NUMBER AND INVOICE.CSR RECNUM = SALESREP.DATAFLEX RECNUM ONE AND DEBTOR.AC NO = ESTIMATE.DEBTOR"; But I dont think those spaces in the Field Names will go through like that. Quote Link to comment https://forums.phpfreaks.com/topic/87595-php-mssql-help/#findComment-448063 Share on other sites More sharing options...
zduchene Posted January 24, 2008 Author Share Posted January 24, 2008 $q = "SELECT estimate.job number, DEBTOR.NAMES, ESTIMATE.details1, debtor.salesrep, salesrep.name AS csr, estimate.due date, estimate.order no, estimate.qty1, estimate.qty2, estimate.qty3, estimate.qty4 FROM LIVEDATA_Dosrun.dbo.ESTIMATE, LIVEDATA_Dosrun.dbo.DEBTOR, LIVEDATA_Dosrun.dbo.SALESREP, LIVEDATA_Dosrun.dbo.INVOICE WHERE ESTIMATE.JOB NUMBER = 53373 AND INVOICE.JOB NO = ESTIMATE.JOB NUMBER AND INVOICE.CSR RECNUM = SALESREP.DATAFLEX RECNUM ONE AND DEBTOR.AC NO = ESTIMATE.DEBTOR"; But I dont think those spaces in the Field Names will go through like that. I did try it without the " and it didn't work because of the spaces in the field names. Does PHP ever allow for spaces in the field names? Quote Link to comment https://forums.phpfreaks.com/topic/87595-php-mssql-help/#findComment-448064 Share on other sites More sharing options...
revraz Posted January 24, 2008 Share Posted January 24, 2008 I didn't think Oracle did. Try using underscores instead. Quote Link to comment https://forums.phpfreaks.com/topic/87595-php-mssql-help/#findComment-448068 Share on other sites More sharing options...
zduchene Posted January 24, 2008 Author Share Posted January 24, 2008 It will be read better if you write it like this: SELECT "estimate"."job number", "DEBTOR"."NAMES", "ESTIMATE"."details1", "debtor"."salesrep", "salesrep"."name" AS "csr", "estimate"."due date", "estimate"."order no", "estimate"."qty1", "estimate"."qty2", "estimate"."qty3", "estimate"."qty4" FROM "LIVEDATA_Dosrun"."dbo"."ESTIMATE", "LIVEDATA_Dosrun"."dbo"."DEBTOR", "LIVEDATA_Dosrun"."dbo"."SALESREP", "LIVEDATA_Dosrun"."dbo"."INVOICE" WHERE "ESTIMATE"."JOB NUMBER" = 53373 AND "INVOICE"."JOB NO" = "ESTIMATE"."JOB NUMBER" AND "INVOICE"."CSR RECNUM" = "SALESREP"."DATAFLEX RECNUM ONE" AND "DEBTOR"."AC NO" = "ESTIMATE"."DEBTOR" That does read much nicer...thanks! Quote Link to comment https://forums.phpfreaks.com/topic/87595-php-mssql-help/#findComment-448069 Share on other sites More sharing options...
zduchene Posted January 24, 2008 Author Share Posted January 24, 2008 I didn't think Oracle did. Try using underscores instead. editing the table names? I can't, the tables are in use by another program...I am trying to extract data because the other program has some limitations. Quote Link to comment https://forums.phpfreaks.com/topic/87595-php-mssql-help/#findComment-448071 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.