Jump to content


Photo

Syntax Error?


  • Please log in to reply
3 replies to this topic

#1 Sephiriz

Sephiriz
  • Members
  • PipPip
  • Member
  • 20 posts
  • LocationNew York

Posted 10 November 2003 - 12:40 AM

Ok, suddenly I\'ve been receiving syntax warnings that never before appeared.

What is wrong with the following query:
$query10 = \"SELECT `Name` FROM `users` WHERE `ID` = \'$_SESSION[user]\'\";
Check out the X Community
PHP Manual | Learn XML | Safe PHP Scripting | Regular Expression Help

Current Project(s):
I. phpRetrograde - PHP5 to PHP4.
II. str_replace_count - Replace a string specified amount of times. III. WordStem - Extract word-stems from strings.

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 10 November 2003 - 12:47 AM

$query10 = \\\"SELECT `Name` FROM `users` WHERE `ID` = \'{$_SESSION[user]}\'\\\";


echo out the session user to be sure it has the value you expect it to.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 Sephiriz

Sephiriz
  • Members
  • PipPip
  • Member
  • 20 posts
  • LocationNew York

Posted 10 November 2003 - 12:59 AM

I see, can you provide me with a link as to where to find documentation for the exact syntax I should use that will always work?

Also, what would be the correct way to make this query:
$query2 = \"SELECT * FROM $Name WHERE Genre = \'$_GET[Genre]\' ORDER BY $View\";
Check out the X Community
PHP Manual | Learn XML | Safe PHP Scripting | Regular Expression Help

Current Project(s):
I. phpRetrograde - PHP5 to PHP4.
II. str_replace_count - Replace a string specified amount of times. III. WordStem - Extract word-stems from strings.

#4 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 10 November 2003 - 03:27 AM

below is information regarding why to used curly braces. they need to be used with arrays so when the variable is parsed within double quotes it knows the breadth of the variable.

http://us2.php.net/m...parsing.complex
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users