johng Posted February 23, 2007 Share Posted February 23, 2007 So I am having a problem passing text with spaces back into a text box. I am able to take it from the text box and put it into the database, and even to take it from the database and put it into a text field on a webpage. But when I try to pass it back into a text box it only passes the first word. The reason I am wanting to pass it back into a text box, in addition to other fields, is to edit it and put it back into the database. To figure out where it is not working, I had it echo out right before the text box, and it prints as the full text, so the problem is somehow in the actual moving it into the text box. I have tried using text and varchar variables, and neither has worked so far. Thanks in advance. -John Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 23, 2007 Share Posted February 23, 2007 Code.... Quote Link to comment Share on other sites More sharing options...
johng Posted February 26, 2007 Author Share Posted February 26, 2007 This is in a table, and in that table there are text boxes and text fields. The text I am trying to pass back is in a text box, code below. There is a lot of code, because there are quite a few fields that I have text or numbers going into, but this is the function line: function display_enter_eserveStaff($eserve_date, $eserve_time=null, $contact_id=null, $oh_cca=null, $oh_cc2=null, $oh_sca=null, $oh_keyers_act=null, $ia_cca=null, $ia_cc2=null, $ia_sca=null, $ia_keyers_act=null, $nv_cca=null, $nv_cc2=null, $nv_sca=null, $nv_keyers_act=null, $eserve_keyers=null, $eserve_notes=null, $row_id=null){ The variable I am trying to pass is $eserve_notes And this is the line of code that creates the text box I am trying to get text back into: echo "<td colspan = 2><input name=\"eserve_notes\" type=\"longtext\" value=$eserve_notes></td>\r"; I echo-ed the variable out right before the text box, and it printed the entire thing, but when it goes into the text box, it only puts one word. I have tried it with text, longtext, and varchar(100). Quote Link to comment Share on other sites More sharing options...
Orio Posted February 26, 2007 Share Posted February 26, 2007 Let me explain what's happening. <?php //Let's say $eserve_notes = "One Two" echo "<td colspan = 2><input name=\"eserve_notes\" type=\"longtext\" value=$eserve_notes></td>"; ?> //Output: <td colspan = 2><input name="eserve_notes" type="longtext" value=One Two></td> As you can see, the "Two" isn't connected to the value, so the browser that receives the html doesn't know what to do with it. So it takes only the "One" and ignores the rest. Solution- add quotes around the value: echo "<td colspan = 2><input name=\"eserve_notes\" type=\"longtext\" value=\"$eserve_notes\"></td>"; Notice the double-quotes around $eserve_notes. Now the browser will know to what "Two" is connected Orio. Quote Link to comment Share on other sites More sharing options...
johng Posted February 26, 2007 Author Share Posted February 26, 2007 Thank you Orio, you are a genius. I had tried to put quotes around it before, but didn't know you had to put the slash before them. Also, how do you get the forum to display as code like you have? EDIT: Also, do you know how to make the text box bigger? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
johng Posted February 26, 2007 Author Share Posted February 26, 2007 I figured out how to make it bigger. Inside the <input...> put size = \"95\" or however long you want it. That was the size that worked for me. Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.