Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004
    Posts
    1

    Exclamation Unanswered: "char" as a table name causing problems in PHP code...

    PHP Code:
    $result mysql_query("SELECT * FROM char",$db); 
    Every time I execute my code, it returns the error

    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\htdocs\index.php on line 37
    However when I change "char" to "login", it works fine...

    All I can figure is causing it is that the table is named "char" which, I'm assuming, is a restricted word...

    I searched all over Google and couldn't figure out what to look for, then tried replacing char with a variable ".$chardb." which is defined as
    PHP Code:
    $chardb="char" 
    ... Which gave the same compilation error.

    So, my question is, besides changing the name of the table, what can I do to make this work?

    Thanks in advance
    ~Neko

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by L33tN3k0
    I searched all over Google and couldn't figure out what to look for
    i do that all the time too

    try putting the table name in backticks --

    select foo from `char`
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •