Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
philip381

Squiggly Bracket Question

Recommended Posts

I am using PHP version 5.3.2 on Windows 7. I have a question pertaining to brackets. (), [], {}.

 

On page 385, the edit_entry.php script, line 51

 

// Define the query.

 

$query = "UPDATE entries SET title='$title', entry='$entry' WHERE entry_id={$_POST['id']}";

 

Why is $_POST['id'] encased in squiggly brackets? Elsewhere, line 41 and 42, for example, the $_POST['title'] is encased in simple ().

 

Does the fact that the variable is being passed through the URL have anything to do with it?

 

Or the fact that the entire SQL statement is enclosed in double quotes, thus requiring the "extra strength" squiggly line encasement?

 

Thank you in advance for your answer.

Share this post


Link to post
Share on other sites

There's a big different if it's a String or an expression. You don't use squiggly brackets in an expression, but they are sometimes required with Strings. (Like when creating this SQL query String). Also note that

 

Use your IDE to figure it how it works

 

Personally, I would prefer to write the string like below, but that's just personal taste.

 

$query = 'UPDATE entries SET title="'.$title.'", entry="'.$entry.'" WHERE entry_id='.$_POST['id'].';

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...