Jump to content


Photo

SQL errors


  • Please log in to reply
5 replies to this topic

#1 kkroo

kkroo
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 23 May 2006 - 06:51 AM

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.php
SHOW KEYS FROM

Failed in get_table_def (show fields) on line337 in/home/***/public_html/gcc/forum/includes/auto_backup.php
SHOW FIELDS FROM

Failed in get_table_content (select *) on line535 in/home/**/public_html/gcc/forum/includes/auto_backup.php
SELECT * FROM

i added a filter to see if the var is empty, and it passes, so i think it may be a syntax error

this is the way the query looks like: SELECT * FROM table_name
SHOW KEYS FROM table_name

does 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

#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 23 May 2006 - 05:22 PM

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
        email_message_die("Failed in get_table_content (select *)", "", __LINE__, __FILE__, "SELECT * FROM $table;");

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!

#3 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 23 May 2006 - 05:37 PM

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.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#4 kkroo

kkroo
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 23 May 2006 - 07:02 PM

so just add `` around all occurances of $table in queries? BTW, is it manditory to have the ; at the end of a query?

#5 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 23 May 2006 - 07:10 PM

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) View Post[/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]


#6 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 23 May 2006 - 07:22 PM

[!--quoteo(post=376438:date=May 23 2006, 12:02 PM:name=kkroo)--][div class=\'quotetop\']QUOTE(kkroo @ May 23 2006, 12:02 PM) View Post[/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.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users