Re: SQL statement in PHP
Matt Davis wrote: Check the manual. The manual shows where following from. > > Can anybody help with this > > If I put the following statement in PHP my browser tells me that there is an > error on the line. > > //create sql statement > $sql = "select Business_Name,Trading_Details where Business_Type = > "Consultancy" and Bassingbourn != "0" from Main"; > > If I remove > > where Business_Type = "Consultancy" and Bassingbourn != "0" > > It work fine, but no variation of the above line works. Am I missing > something really obvious. Please help as I am very quickly becoming bald. > > Matt. > > - > Before posting, please check: >http://www.mysql.com/manual.php (the manual) >http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail ><[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: SQL statement in PHP
On Fri, Feb 16, 2001 at 12:43:15PM -, Matt Davis wrote: > Can anybody help with this > > If I put the following statement in PHP my browser tells me that there is an > error on the line. > > //create sql statement > $sql = "select Business_Name,Trading_Details where Business_Type = > "Consultancy" and Bassingbourn != "0" from Main"; > You need to escape the double-quotes in the double-quoted string. I don't know PHP, but usually something like below should work: //create sql statement $sql = "select Business_Name,Trading_Details where Business_Type = \"Consultancy\" and Bassingbourn != \"0\" from Main"; Regards, Fred. -- Fred van Engen XO Communications B.V. email: [EMAIL PROTECTED] Televisieweg 2 tel: +31 36 5462400 1322 AC Almere fax: +31 36 5462424 The Netherlands - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: SQL statement in PHP
PHP sees the first " of "Consultancy" as being the end of the variable $sql. To get round this, change the " to ' inside the statement (e.g. ...where Business_Type = 'Consultancy' and...) HTH Jon -Original Message- From: Matt Davis [mailto:[EMAIL PROTECTED]] Sent: 16 February 2001 12:43 To: mysql Subject: SQL statement in PHP Can anybody help with this If I put the following statement in PHP my browser tells me that there is an error on the line. //create sql statement $sql = "select Business_Name,Trading_Details where Business_Type = "Consultancy" and Bassingbourn != "0" from Main"; If I remove where Business_Type = "Consultancy" and Bassingbourn != "0" It work fine, but no variation of the above line works. Am I missing something really obvious. Please help as I am very quickly becoming bald. Matt. - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: SQL statement in PHP
Take a look at your query once again: "select/../"Consultancy"/.../" You can have "" inside "". The ways to do it, so that it would work: -> use '$somethinghere' instead of "$something" or -> use \"$somethinghere\" instead of second "$something" or -> use '".$somthinghere."' instead of ... Cheers Siim Einfeldt > Can anybody help with this > > If I put the following statement in PHP my browser tells me that there is an > error on the line. > > //create sql statement > $sql = "select Business_Name,Trading_Details where Business_Type = > "Consultancy" and Bassingbourn != "0" from Main"; > > If I remove > > where Business_Type = "Consultancy" and Bassingbourn != "0" > > It work fine, but no variation of the above line works. Am I missing > something really obvious. Please help as I am very quickly becoming bald. > > > Matt. > > > - > Before posting, please check: >http://www.mysql.com/manual.php (the manual) >http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
SQL statement in PHP
Can anybody help with this If I put the following statement in PHP my browser tells me that there is an error on the line. //create sql statement $sql = "select Business_Name,Trading_Details where Business_Type = "Consultancy" and Bassingbourn != "0" from Main"; If I remove where Business_Type = "Consultancy" and Bassingbourn != "0" It work fine, but no variation of the above line works. Am I missing something really obvious. Please help as I am very quickly becoming bald. Matt. - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php