kkroo Posted May 23, 2006 Share Posted May 23, 2006 I created an automatic backup script, and occasionally, i will get some errors like:FAILED IN get_table_def (show keys) on line372 in/home/***/public_html/forum/includes/auto_backup.phpSHOW KEYS FROMFailed in get_table_def (show fields) on line337 in/home/***/public_html/gcc/forum/includes/auto_backup.phpSHOW FIELDS FROMFailed in get_table_content (select *) on line535 in/home/**/public_html/gcc/forum/includes/auto_backup.phpSELECT * FROM i added a filter to see if the var is empty, and it passes, so i think it may be a syntax errorthis is the way the query looks like: SELECT * FROM table_name SHOW KEYS FROM table_namedoes it maybe have to be like this: SELECT * FROM `table_name` SHOW KEYS FROM `table_name`here is the script:[a href=\"http://phpbb-login.sourceforge.net/forum/dload.php?action=file&file_id=13\" target=\"_blank\"]http://phpbb-login.sourceforge.net/forum/d...file&file_id=13[/a]Any help will be highly appreciated Link to comment https://forums.phpfreaks.com/topic/10241-sql-errors/ Share on other sites More sharing options...
michaellunsford Posted May 23, 2006 Share Posted May 23, 2006 the script is pretty complex (almost 800 lines) and the specific error is never reported. I looked at the code and didn't find anything until I got to line 535 [code] email_message_die("Failed in get_table_content (select *)", "", __LINE__, __FILE__, "SELECT * FROM $table;");[/code]it's dumping your query as the error message (or so it would appear). The query is "SELECT * FROM" -- which appears to be missing the $table variable. 535 is inside a function called get_table_content_mysql() -- the function expects to receive $table when called -- but I can't find where the function is called! Link to comment https://forums.phpfreaks.com/topic/10241-sql-errors/#findComment-38306 Share on other sites More sharing options...
ryanlwh Posted May 23, 2006 Share Posted May 23, 2006 if $table is somehow a keyword in mysql, then you'll get the error. if you surround $table with `` then you are telling mysql to not treat that part as a keyword, which should solve the problem. Link to comment https://forums.phpfreaks.com/topic/10241-sql-errors/#findComment-38314 Share on other sites More sharing options...
kkroo Posted May 23, 2006 Author Share Posted May 23, 2006 so just add `` around all occurances of $table in queries? BTW, is it manditory to have the ; at the end of a query? Link to comment https://forums.phpfreaks.com/topic/10241-sql-errors/#findComment-38343 Share on other sites More sharing options...
michaellunsford Posted May 23, 2006 Share Posted May 23, 2006 oops, my bad --- not supposed to use that at all.[!--quoteo(post=376438:date=May 23 2006, 02:02 PM:name=kkroo)--][div class=\'quotetop\']QUOTE(kkroo @ May 23 2006, 02:02 PM) [snapback]376438[/snapback][/div][div class=\'quotemain\'][!--quotec--]so just add `` around all occurances of $table in queries? BTW, is it manditory to have the ; at the end of a query?[/quote] Link to comment https://forums.phpfreaks.com/topic/10241-sql-errors/#findComment-38346 Share on other sites More sharing options...
ryanlwh Posted May 23, 2006 Share Posted May 23, 2006 [!--quoteo(post=376438:date=May 23 2006, 12:02 PM:name=kkroo)--][div class=\'quotetop\']QUOTE(kkroo @ May 23 2006, 12:02 PM) [snapback]376438[/snapback][/div][div class=\'quotemain\'][!--quotec--]so just add `` around all occurances of $table in queries? BTW, is it manditory to have the ; at the end of a query?[/quote]Theoretically, ";" is needed to indicate the end of a query, but in php, it's not mandatory. Link to comment https://forums.phpfreaks.com/topic/10241-sql-errors/#findComment-38349 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.