If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > "char" as a table name causing problems in PHP code...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-22-04, 04:23
L33tN3k0 L33tN3k0 is offline
Registered User
 
Join Date: Aug 2004
Posts: 1
Exclamation "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

Quote:
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
Reply With Quote
  #2 (permalink)  
Old 08-22-04, 07:47
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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`
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On