0

How would you add a variable within quotations marks? Here's what I'm trying to do but it's not working.

header("Location: mainpage.php?note=".$note_title);

Also is there a way to indent blocks of code on Stack Overflow without having to do four spaces on each individual line?

6
  • That should work (as long as $note_title is defined and contains what you want it to contain). Whats the problem? Your second question: No. Commented Jan 16, 2012 at 18:04
  • 4
    To indent: select you code ond press Ctrl+K Commented Jan 16, 2012 at 18:05
  • 1
    You can highlight a block of code with your mouse and then click the {}, it will add the spaces automatically for you. Commented Jan 16, 2012 at 18:06
  • 1
    Indent however you like or not at all then highlight the code block and click on the {} button and it will indent for a code block for you. Commented Jan 16, 2012 at 18:06
  • 1
    write exit() after header() Commented Jan 16, 2012 at 18:09

3 Answers 3

1

you mean like:

header("Location: mainpage.php?note=$note_title");

This is the standard way. If it is not working the problem is not with the code you posted.

As for the second part, you can use tabs, but not effectively in a browser window usually.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't know if there's a "standard way", that's just another way of doing something that should work in the example in the question.
Fair enough. "A" standard way then.
1

It does work. , as KingCrunch said.

<?php
$note_title="24";
header("Location: mainpage.php?note=".$note_title);
?>

Comments

0

Add double quotes to your value like that:

$note_title = '"your_value"';

1 Comment

I think you're thinking that his problem is with breaks in the $note_title text. It may be, but with the information given I don't think it's reasonable to assume.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.