1

I'm dynamically creating a table from a MySQL query. For some reason, the 'notes' field below is only returning the first word of the string, although when I test it with echo($notes) it shows up just fine. $status is similarly set, and also is fine. What am I missing? I assume it has something to do with prepopulating the text field with the value. I'm using codeigniter.

$notes = empty($row["notes"]) ? "None" : $row["notes"];
    echo($notes);
    echo('
    <tr class="even">
        <td class="status-icons">'.$error_level.'</td>
        <td>'.$row["name"].'</td>
        <td>'.$status.'</td>
        <td class="notes-col">
          <input type="text" name="submit_notes" value='.$notes.' class="notes-copy">
        </td>
    </tr>'
5
  • Probably not related, but echo is not a function, the correct way is 'echo $notes;' Commented Jul 26, 2013 at 22:08
  • Good to know, but that's just there for debugging. Is there a difference, or is that just a standard? Commented Jul 26, 2013 at 22:08
  • according to the manual it can be used as a function but will not always work like it. Commented Jul 26, 2013 at 22:11
  • @thumbtackthief, just a standard used to differentiate functions from language constructs. echo is not a function in php Commented Jul 26, 2013 at 22:11
  • possible duplicate of Only first word In a multi word variable is being displayed Commented Jul 30, 2013 at 15:58

1 Answer 1

14

replace this

   value='.$notes.'

with

    value="'.$notes.'"

the double quotes are for the Value because it originally has two quotes like: value=""

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

4 Comments

always the little things :) like a space before the opening php tag -_-
@MarkBasmayor sorry i didnt mean to beat you to it :), if i knew you will post it i should let you :) .
should probably urlencode the value as well or a stray ' is going to blow it up.
@Orangepill I'm using codeigniter and django--isn't that automatic? I tested some values with quotes and didn't seem to have a problem.

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.