Jump to content

[SOLVED] PHP SQL character issue


millercj

Recommended Posts

I'm running a sql query and I have a table that houses coded names for classes, one is named "5-1"

 

my query loops and is saved to an array by this statement:

$classes[$i] [0] = $nextresult['class_name'];

 

And then later does this:

$tblname=$classes [$i][0];

 

for the record "5-1" by the time it goes through this it's interpreting table "5-1" as 4 (the result of 5 minus 1)

 

How can i fix this?!

 

Link to comment
https://forums.phpfreaks.com/topic/150649-solved-php-sql-character-issue/
Share on other sites

It would help if you showed how this is used, but based on the variable being called $tblname, you are likely using this in a query -

 

A) You should not be using numbers for table names, and

B) If you are using numbers for table name, you must enclose them in back-ticks so that they are treated as an identifier instead of a math expression.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.