Jump to content


Photo

Interesting "bug"


  • Please log in to reply
4 replies to this topic

#1 gorilla0

gorilla0
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 November 2003 - 06:49 PM

I noticed something quite strange & wondering if anyone has come across this:
I created a record set & wanted to make the table_name a variable. I declared the variable, but Dreamweaver wanted to parse it as just a string rather than a variable. I tested to see if the variable was set properly and it was. Here is an example of what I mean:

$table = \"colors\";

$sql = \"select * from $table\";

it tries to find a table name called \"$tables\" rather than \"colors\". This is VERY VERY basic stuff, I am really suprised at such a sloppy error. Anybody seen this?

#2 Arenium

Arenium
  • Staff Alumni
  • Advanced Member
  • 111 posts
  • LocationMassachusetts

Posted 13 November 2003 - 11:41 PM

its not an error, single-quote the variable as the table name

[php:1:2fe72d1b6e]
$table = \"roles\";
mysql_query(\"SELECT * FROM \'$table\' \");
[/php:1:2fe72d1b6e]

#3 gorilla0

gorilla0
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 November 2003 - 11:46 PM

Thanks, if the solution works, it will save some redundant work, but I have to say:
Technically, it is a bug, since within regular PHP coding there is absolutely no need to enclose a table_name in single quotes. In fact, I know of an instance where it needs to be done, whether it me MS SQL, Oracle or PostGres. I am a six - seven-month newbie to Studio MX, but not to PHP development by a longshot, so I would definitely consider this a DreamWeaver bug. MacroMedia Gods, here me :-P

Additionally, I have not tried your fix, but am curious of the result.

#4 Arenium

Arenium
  • Staff Alumni
  • Advanced Member
  • 111 posts
  • LocationMassachusetts

Posted 13 November 2003 - 11:54 PM

how is this a dreamweaver bug? lol

you write the code, php does it, mysql holds the data php uses, simple

dreamweaver is just a program we use to write the code. try the same code in notepad or any other editor, its the languages limitations.

a dreamweaver bug is if something in the GUI glitches, or if it doesn\'t display your code as it should is design view, or vice versa...the possibilities go on

#5 gorilla0

gorilla0
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 November 2003 - 11:59 PM

Let me be specific:

$table_name = \"my_table\";
$sql = \"select * from $table_name\";
$res = mysql_query($sql);

This WORKS all day long in averyday PHP.

in DreamWeaver\'s Recordset function, if you edit the code manually to reflect the same thing, it errors and says that $table_name does not exist.(We are not looking for $table_name, we are looking for the value of $table_name, that being \"my_table\") In other words, it views the $ as a regular character rather than understanding that it is a variable. Is that more clear? Sorry if I was not as specific in my first example.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users