ellchr3 Posted April 8, 2013 Share Posted April 8, 2013 Hello, I'm trying to display the results of my query in a text box so that they can be edited, if need be, and updated in the database. I'm getting the error below, with the code below. I've tried a couple of different ways to format the "value" of the text box as you can see by the second one that's commented out and still a no go. Thanks for any help in advance guys. The error below is referring to the code just below here. echo "<td><input type="text" name="firstname" value="$firstname"></td>"; Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\ $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} echo "<table><tr>"; echo "<th>First Name</th>"; echo "<th>Middle Initial</th>"; echo "<th>Last Name</th>"; echo "<th>Full Name</th>"; echo "<th>Provider ID</th></tr>"; while (odbc_fetch_row($rs)) { $firstname=odbc_result($rs,"provider_first_name"); $middleinitial=odbc_result($rs,"provider_middle_name"); $lastname=odbc_result($rs,"provider_last_name"); $fullname=odbc_result($rs,"provider_full_name"); $provider_id=odbc_result($rs,"provider_id"); echo "<tr><td>$firstname</td>"; echo "<td><input type="text" name="firstname" value="$firstname"></td>"; echo "<td>$middleinitial</td>"; echo "<td>$lastname</td>"; echo "<td>$fullname</td>"; echo "<td>$provider_id</td>"; // echo "<td><input type="text" name="textfield" value='".$providerid."'"></td>"; echo "<td>$providerid</td></tr>"; } odbc_close($conn); Quote Link to comment https://forums.phpfreaks.com/topic/276692-display-results-in-a-text-box-to-be-edited-for-update-query/ Share on other sites More sharing options...
Solution Jessica Posted April 8, 2013 Solution Share Posted April 8, 2013 You need to escape the double quotes within the string. Read the manual section on string. Quote Link to comment https://forums.phpfreaks.com/topic/276692-display-results-in-a-text-box-to-be-edited-for-update-query/#findComment-1423579 Share on other sites More sharing options...
ellchr3 Posted April 8, 2013 Author Share Posted April 8, 2013 Jessica, Thanks for your reply. I'm assuming this is to be done to the "value=..." portion of the statement? I've tried lots of different combinations using the slash for escaping the string and even tried the addslashes function that I found in searching and couldn't get it to work. I'm still fairly new to PHP so I do apologize for my ignorance at this point You need to escape the double quotes within the string. Read the manual section on string. Quote Link to comment https://forums.phpfreaks.com/topic/276692-display-results-in-a-text-box-to-be-edited-for-update-query/#findComment-1423590 Share on other sites More sharing options...
Strider64 Posted April 8, 2013 Share Posted April 8, 2013 You escape double quotes this way echo "<td><input type=\"text\" name=\"textfield\" value=\"" . $providerid . "\" ></td>"; Quote Link to comment https://forums.phpfreaks.com/topic/276692-display-results-in-a-text-box-to-be-edited-for-update-query/#findComment-1423592 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.