Re: [PHP] Database error: Invalid SQL:
Usually you need to specify the type: inner join, left join, right join, straight join etc. OTThat sounds like the good old times when we did air-to-air refueling :oP /OT Sorry, had to :P - Original Message - From: Chris [EMAIL PROTECTED] To: wisuttorn [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Thursday, May 24, 2007 7:34 AM Subject: Re: [PHP] Database error: Invalid SQL: wisuttorn wrote: I have a problem please help me when i loged in to egroup this show Database error: Invalid SQL: SELECT DISTINCT egw_cal_repeats.*,egw_cal.*,cal_start,cal_end,cal_recur_date FROM egw_cal JOIN egw_cal_dates ON egw_cal.cal_id=egw_cal_dates.cal_id JOIN egw_cal_user ON egw_cal.cal_id=egw_cal_user.cal_id LEFT JOIN egw_cal_repeats ON egw_cal.cal_id=egw_cal_repeats.cal_id WHERE (cal_user_type='u' AND cal_user_id IN (6,-1)) AND cal_status != 'R' AND 1179939600 cal_end AND cal_start 1180025999 AND (recur_type IS NULL AND cal_recur_date=0 OR cal_recur_date=cal_start) ORDER BY cal_start mysql Error: 1064 (You have an error in your SQL syntax near 'ON egw_cal.cal_id=egw_cal_dates.cal_id JOIN egw_cal_user ON egw_cal.cal_id=egw_c' at line 1) I guess that whatever database you are using doesn't allow 'JOIN' as a join type. Usually you need to specify the type: inner join, left join, right join, straight join etc. Ask your specific database list about it. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database error: Invalid SQL:
On Wed, May 23, 2007 11:42 pm, wisuttorn wrote: I have a problem please help me when i loged in to egroup this show Database error: Invalid SQL: SELECT DISTINCT egw_cal_repeats.*,egw_cal.*,cal_start,cal_end,cal_recur_date FROM egw_cal JOIN egw_cal_dates ON egw_cal.cal_id=egw_cal_dates.cal_id JOIN egw_cal_user ON egw_cal.cal_id=egw_cal_user.cal_id LEFT JOIN egw_cal_repeats ON egw_cal.cal_id=egw_cal_repeats.cal_id WHERE (cal_user_type='u' AND cal_user_id IN (6,-1)) AND cal_status != 'R' AND 1179939600 cal_end AND cal_start 1180025999 AND (recur_type IS NULL AND cal_recur_date=0 OR cal_recur_date=cal_start) ORDER BY cal_start mysql Error: 1064 (You have an error in your SQL syntax near 'ON egw_cal.cal_id=egw_cal_dates.cal_id JOIN egw_cal_user ON egw_cal.cal_id=egw_c' at line 1) This is an SQL error. Ask an SQL list. At a guess, I'd say the version of SQL you have doesn't support all JOIN types. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Database error: Invalid SQL:
I have a problem please help me when i loged in to egroup this show Database error: Invalid SQL: SELECT DISTINCT egw_cal_repeats.*,egw_cal.*,cal_start,cal_end,cal_recur_date FROM egw_cal JOIN egw_cal_dates ON egw_cal.cal_id=egw_cal_dates.cal_id JOIN egw_cal_user ON egw_cal.cal_id=egw_cal_user.cal_id LEFT JOIN egw_cal_repeats ON egw_cal.cal_id=egw_cal_repeats.cal_id WHERE (cal_user_type='u' AND cal_user_id IN (6,-1)) AND cal_status != 'R' AND 1179939600 cal_end AND cal_start 1180025999 AND (recur_type IS NULL AND cal_recur_date=0 OR cal_recur_date=cal_start) ORDER BY cal_start mysql Error: 1064 (You have an error in your SQL syntax near 'ON egw_cal.cal_id=egw_cal_dates.cal_id JOIN egw_cal_user ON egw_cal.cal_id=egw_c' at line 1) File: /home/lecturer/account/wisuttorn/public_html/work/calendar/inc/class.socal.inc.php Line: 372 Function: egw_db::select / socal::search / bocal::search / uiviews::day / uiviews::index / execmethod(calendar.uiviews.index) Session halted. How can i fix this problem? Thank you -- View this message in context: http://www.nabble.com/Database-error%3A-Invalid-SQL%3A-tf3807948.html#a10777304 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database error: Invalid SQL:
wisuttorn wrote: I have a problem please help me when i loged in to egroup this show Database error: Invalid SQL: SELECT DISTINCT egw_cal_repeats.*,egw_cal.*,cal_start,cal_end,cal_recur_date FROM egw_cal JOIN egw_cal_dates ON egw_cal.cal_id=egw_cal_dates.cal_id JOIN egw_cal_user ON egw_cal.cal_id=egw_cal_user.cal_id LEFT JOIN egw_cal_repeats ON egw_cal.cal_id=egw_cal_repeats.cal_id WHERE (cal_user_type='u' AND cal_user_id IN (6,-1)) AND cal_status != 'R' AND 1179939600 cal_end AND cal_start 1180025999 AND (recur_type IS NULL AND cal_recur_date=0 OR cal_recur_date=cal_start) ORDER BY cal_start mysql Error: 1064 (You have an error in your SQL syntax near 'ON egw_cal.cal_id=egw_cal_dates.cal_id JOIN egw_cal_user ON egw_cal.cal_id=egw_c' at line 1) I guess that whatever database you are using doesn't allow 'JOIN' as a join type. Usually you need to specify the type: inner join, left join, right join, straight join etc. Ask your specific database list about it. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database Error
Check syntax for mysql_query() function. You don't need to pass the database name. See here: http://www.php.net/manual/en/function.mysql-query.php You're query method then becomes: function query($query) { $connection = mysql_connect($this-hostname, $this-user, $this-pass) or die (Cannot connect to database); mysql_select_db ($this-db, $connection); // You forgot this step // Also change the following line, you don't need // to pass the database name $ret = mysql _query($query, $connection) or die (Error in query: $query); return $ret; } Robert Zwink http://www.zwink.net -Original Message- From: Navid Yar [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 06, 2002 4:59 PM To: 'Robert V. Zwink' Subject: RE: [PHP] Database Error I just tried that Robert. It still gives me the same error that it did before. There is no error after the mysql_connect. It definitely is connecting. If it didn't connect then it wouldn't pass the query to the database in the first place and spit out an error on the SQL syntax. I checked the syntax on the MySQL command line and it worked just fine. So it's not the syntax either. I don't know what it could be :( -Original Message- From: Robert V. Zwink [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 07, 2002 3:42 PM To: Navid Yar Subject: RE: [PHP] Database Error Could you try changing your query() method to function query($query) { $connection = mysql_connect($this-hostname, $this-user, $this-pass) or die (Cannot connect to database); echo mysql_error(); // put this here $ret = mysql _query($this-db, $query, $connection) or die (Error in query: $query); return $ret; } I think echoing out the mysql_error() will help pinpoint the problem. Seems like it is unable to connect? Robert Zwink http://www.zwink.net/daid.php -Original Message- From: Navid Yar [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 06, 2002 4:42 PM To: [EMAIL PROTECTED] Subject: RE: [PHP] Database Error Yes, Jason. I posted it earlier, but here it is again. // Error I'm getting Error in query: SELECT label FROM menu WHERE id = 3 Warning: Supplied argument is not a valid MySQL result resource in e:\localhost\menu\menu.class.php on line 47 // Object being called from get.php ?php require(menu.class.php); $obj = new Menu(); echo $obj-get_label(1); ? // Class in the file menu.class.php class Menu { var $hostname; var $user; var $pass; var $db; var $table; function Menu() { $this-set_database_parameters(localhost, username, password, apps, menu); } function set_database_parameters($hostname, $user, $password, $db, $table) { $this-hostname = $hostname; $this-user = $user; $this-password = $password; $this-db = $db; $this-table = $table; } function query($query) { $connection = mysql_connect($this-hostname, $this-user, $this-pass) or die (Cannot connect to database); $ret = mysql _query($this-db, $query, $connection) or die (Error in query: $query); return $ret; } function get_label($id) { $query = SELECT label FROM $this-table WHERE id = $id; $result = $this-query($query); $row = mysql_fetch_row($result); return $row[0]; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Database Error
Ok guys, I need help with this one. I am getting the error: Error in query: SELECT label FROM menu WHERE id = '1'. Why am I getting this error? It seems right to me. I have the following code to call the class object, and I listed the class below it (I'm fairly new to classes): // Object being called from get.php ?php require(menu.class.php); $obj = new Menu(); echo $obj-get_label(1); ? // Class in the file menu.class.php class Menu { var $hostname; var $user; var $pass; var $db; var $table; function Menu() { $this-set_database_parameters(localhost, username, password, apps, menu); } function set_database_parameters($hostname, $user, $password, $db, $table) { $this-hostname = $hostname; $this-user = $user; $this-password = $password; $this-db = $db; $this-table = $table; } function query($query) { $connection = mysql_connect($this-hostname, $this-user, $this-pass) or die (Cannot connect to database); $ret = mysql_db_query($this-db, $query, $connection) or die (Error in query: $query); return $ret; } function get_label($id) { $query = SELECT label FROM $this-table WHERE id = '$id'; $result = $this-query($query); $row = mysql_fetch_row($result); return $row[0]; } } Thanks to anyone, in advance, that can help me with this one. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database Error
On Wednesday 06 March 2002 17:56, Navid Yar wrote: Ok guys, I need help with this one. I am getting the error: Error in query: SELECT label FROM menu WHERE id = '1'. Why am I getting this error? It seems right to me. I have the following code to call the class object, and I listed the class below it (I'm fairly new to classes): Try plugging your query directly into mysql (at the command-line) to see whether it's a mysql problem or a php one. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* If anything can go wrong, it will. -- Edsel Murphy */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database Error
I'm thinking that it probably has to do with the quoting scheme or something else. I tried it on the command line, and it worked fine. I don't even think it matters what types of quotes I use around the id field. I tried both (single and double) on the command line, and it worked just fine. In other words, the SQL is fine, and there's nothing wrong with it. It must either be how I placed the sql statement into the query or how the class is executed. I'm not sure. It might entirely be something else. But, any help on this is really appreciated. -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 07, 2002 3:51 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Database Error On Wednesday 06 March 2002 17:56, Navid Yar wrote: Ok guys, I need help with this one. I am getting the error: Error in query: SELECT label FROM menu WHERE id = '1'. Why am I getting this error? It seems right to me. I have the following code to call the class object, and I listed the class below it (I'm fairly new to classes): Try plugging your query directly into mysql (at the command-line) to see whether it's a mysql problem or a php one. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* If anything can go wrong, it will. -- Edsel Murphy */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database Error
On Wednesday 06 March 2002 18:27, Navid Yar wrote: I'm thinking that it probably has to do with the quoting scheme or something else. I tried it on the command line, and it worked fine. I don't even think it matters what types of quotes I use around the id field. I tried both (single and double) on the command line, and it worked just fine. In other words, the SQL is fine, and there's nothing wrong with it. It must either be how I placed the sql statement into the query or how the class is executed. I'm not sure. It might entirely be something else. But, any help on this is really appreciated. If 'id' is a numeric field then you should not use quotes: SELECT label FROM menu WHERE id = 1 If it's a character field then it doesn't matter whether you use single or double quotes. One thing you could try doing is to rewrite your code so that it doesn't use mysql_db_query() as it has been deprecated as of php-4.0.6. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* If Patrick Henry thought that taxation without representation was bad, he should see how bad it is with representation. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database Error
I changed mysql_db_query() to mysql_query(). I took the quotes away from the id. It still gives me an error: Error in query: SELECT label FROM menu WHERE id = 3 Where else could I be going wrong? -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 07, 2002 4:36 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Database Error On Wednesday 06 March 2002 18:27, Navid Yar wrote: I'm thinking that it probably has to do with the quoting scheme or something else. I tried it on the command line, and it worked fine. I don't even think it matters what types of quotes I use around the id field. I tried both (single and double) on the command line, and it worked just fine. In other words, the SQL is fine, and there's nothing wrong with it. It must either be how I placed the sql statement into the query or how the class is executed. I'm not sure. It might entirely be something else. But, any help on this is really appreciated. If 'id' is a numeric field then you should not use quotes: SELECT label FROM menu WHERE id = 1 If it's a character field then it doesn't matter whether you use single or double quotes. One thing you could try doing is to rewrite your code so that it doesn't use mysql_db_query() as it has been deprecated as of php-4.0.6. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* If Patrick Henry thought that taxation without representation was bad, he should see how bad it is with representation. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database Error
Yes, Jason. I posted it earlier, but here it is again. // Error I'm getting Error in query: SELECT label FROM menu WHERE id = 3 Warning: Supplied argument is not a valid MySQL result resource in e:\localhost\menu\menu.class.php on line 47 // Object being called from get.php ?php require(menu.class.php); $obj = new Menu(); echo $obj-get_label(1); ? // Class in the file menu.class.php class Menu { var $hostname; var $user; var $pass; var $db; var $table; function Menu() { $this-set_database_parameters(localhost, username, password, apps, menu); } function set_database_parameters($hostname, $user, $password, $db, $table) { $this-hostname = $hostname; $this-user = $user; $this-password = $password; $this-db = $db; $this-table = $table; } function query($query) { $connection = mysql_connect($this-hostname, $this-user, $this-pass) or die (Cannot connect to database); $ret = mysql _query($this-db, $query, $connection) or die (Error in query: $query); return $ret; } function get_label($id) { $query = SELECT label FROM $this-table WHERE id = $id; $result = $this-query($query); $row = mysql_fetch_row($result); return $row[0]; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database Error
I just tried that Robert. It still gives me the same error that it did before. There is no error after the mysql_connect. It definitely is connecting. If it didn't connect then it wouldn't pass the query to the database in the first place and spit out an error on the SQL syntax. I checked the syntax on the MySQL command line and it worked just fine. So it's not the syntax either. I don't know what it could be :( -Original Message- From: Robert V. Zwink [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 07, 2002 3:42 PM To: Navid Yar Subject: RE: [PHP] Database Error Could you try changing your query() method to function query($query) { $connection = mysql_connect($this-hostname, $this-user, $this-pass) or die (Cannot connect to database); echo mysql_error(); // put this here $ret = mysql _query($this-db, $query, $connection) or die (Error in query: $query); return $ret; } I think echoing out the mysql_error() will help pinpoint the problem. Seems like it is unable to connect? Robert Zwink http://www.zwink.net/daid.php -Original Message- From: Navid Yar [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 06, 2002 4:42 PM To: [EMAIL PROTECTED] Subject: RE: [PHP] Database Error Yes, Jason. I posted it earlier, but here it is again. // Error I'm getting Error in query: SELECT label FROM menu WHERE id = 3 Warning: Supplied argument is not a valid MySQL result resource in e:\localhost\menu\menu.class.php on line 47 // Object being called from get.php ?php require(menu.class.php); $obj = new Menu(); echo $obj-get_label(1); ? // Class in the file menu.class.php class Menu { var $hostname; var $user; var $pass; var $db; var $table; function Menu() { $this-set_database_parameters(localhost, username, password, apps, menu); } function set_database_parameters($hostname, $user, $password, $db, $table) { $this-hostname = $hostname; $this-user = $user; $this-password = $password; $this-db = $db; $this-table = $table; } function query($query) { $connection = mysql_connect($this-hostname, $this-user, $this-pass) or die (Cannot connect to database); $ret = mysql _query($this-db, $query, $connection) or die (Error in query: $query); return $ret; } function get_label($id) { $query = SELECT label FROM $this-table WHERE id = $id; $result = $this-query($query); $row = mysql_fetch_row($result); return $row[0]; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php