Forum Moderators: coopster

Message Too Old, No Replies

PHP/MySQL question

update table

         

StoutFiles

9:27 pm on Jul 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm having trouble updating a table in which the name of the column has a space in it.

Example: Big Red

$result = mysql_query("UPDATE example SET Big Red='1' WHERE Blue='2'") or die(mysql_error());

It thinks I'm trying Red='1'. I've tried 'Big Red'='1' but that doesn't work either. Any ideas?

Little_G

9:41 pm on Jul 8, 2008 (gmt 0)

10+ Year Member



Hi,

Try putting back ticks (`) around it.

Andrew

eelixduppy

9:44 pm on Jul 8, 2008 (gmt 0)



It's probably a good idea to omit spaces from column names. If you have to, use an underscore instead. But yes, the prime character around the name should work, as suggested above.

StoutFiles

9:51 pm on Jul 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Back ticks worked. I made an example in phymyadmin to see how it would update the column and figured it out with that, however, thank you both a lot for responding. It frustrated me for a while.

They aren't my columns; I just have to use the database for a project at work.