Re: SQL Quick problem

From: Date: Sat, 02 Dec 2000 23:19:10 +0000
Subject: Re: SQL Quick problem
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-4964@lists.php.net to get a copy of this message
Like was said before, when executing MySQL statements with PHP, there's no need to end your statement with a semicolon. It will be executed either way (I think; the semicolon MAY throw it off, but I'm really not sure on that one). Furthermore, since the error is on the $query = ... line and not the actual line of mysql_query(), the SQL has nothing to do with the problem. It is PHP syntax somewhere prior to that line. I second Doug's suggestions: : > Forgotton semicolon at the end of a previous PHP statement : > A beginning quotation mark with no ending quotation mark in an earlier : > statement : > Mismatched curly braces : > Mismatched parentheses in an earlier statement Take a look at that stuff, and if you're still having problems, recreate the problem in a small, simple script and send the whole thing so we can check for problems prior to the actual SQL. Toby Butzon [ criticism spurs improvement ] ----- Original Message ----- From: "Fábio Ottolini" <fabio.ottolini@uol.com.br> To: "db php" <php-db@lists.php.net> Sent: Saturday, December 02, 2000 6:12 PM Subject: Re: [PHP-DB] SQL Quick problem : The parentheses in this case is something related to my personal style. : Working with double quotes works fine. What I believe that is wrong is that : there is no ";" after the name of the table (clubs). As far as I know each : and every MySQL statement must end with a ";", right? Ok, there are some : excpetions. But in this casa it is mandatory to use the ";" at the end of : the sentence. This tells MySQL to execute the statement. So if we forget : about the parentheses the PHP should look like this: : : $query = "SELECT name, city FROM clubs;"; : : Please correct if I am wrong. : : Best regards, : : Fábio Ottolini : : ----- Original Message ----- : From: "Doug Semig" <dougslist@semig.com> : To: <php-db@lists.php.net> : Sent: Saturday, December 02, 2000 8:15 PM : Subject: Re: [PHP-DB] SQL Quick problem : : : > Actually, you're not supposed to use a semicolon at the end of a query. : > Since PHP uses the MySQL C API, you can find confirmation of this in the : > MySQL C API documentation. : > : http://www.mysql.com/documentation/mysql/bychapter/manual_Clients.html#mysql : > _query section 22.4.40.1, third sentence. : > : > I see no reason to expect that putting parentheses around the value he's : > trying to assign to $query will fix it either. : > : > In truth, I see nothing wrong with the statement as it appears. Since the : > problem is a parse error in the PHP assignemnt statement, I suspect : > something else that he hasn't shown us. Usually, it's something like: : > : > Forgotton semicolon at the end of a previous PHP statement : > A beginning quotation mark with no ending quotation mark in an earlier : > statement : > Mismatched curly braces : > Mismatched parentheses in an earlier statement : > : > But it's impossible to tell, since we weren't given the line that is : > actually causing the error, but only the line at which PHP discovers a : > problem (and the line after it). : > : > Doug : > : > At 07:33 PM 12/2/00 -0200, =?Windows-1252?Q?F=E1bio_Ottolini?= wrote: : > >$query = ("SELECT name, city FROM clubs;"); : > > : > >Try this. You forgot the ";" at the end of the query. : > > : > >Best regards, : > > : > >Fábio Ottolini : > > : > > : > > ----- Original Message ----- : > > From: Howard Sanders : > > To: php-db@lists.php.net : > > Sent: Saturday, December 02, 2000 7:08 PM : > > Subject: [PHP-DB] SQL Quick problem : > > : > > : > > Hi : > > Could someone tell me what is wrong with : > > $query = "SELECT name, city FROM clubs"; : > > $result = mysql_query ($query) : > > or die ("Query failed"); : > > in a mySQL database query using PHP? : > > I get a Parse error on the $query..... line : > > : > > Many thanks for your help : > > Howard : > > : > : > : > -- : > PHP Database Mailing List (http://www.php.net/) : > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net : > For additional commands, e-mail: php-db-help@lists.php.net : > To contact the list administrators, e-mail: php-list-admin@lists.php.net : > : > : : : : -- : PHP Database Mailing List (http://www.php.net/) : To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net : For additional commands, e-mail: php-db-help@lists.php.net : To contact the list administrators, e-mail: php-list-admin@lists.php.net : :

« previous php.db (#4964) next »