0

The snippet of the PHP script below works for the most part... except for the fact that $rows[from_location_1] and $rows['to_location_1'] are not displaying all of the data.

The data consist of building code (letters) followed by a space then floor number/room number. example: NAC 1/200A. The script is displaying only the building code (NAC)

Note: the statement: echo "$rows[from_location_1]"; show all of the data.

I'm totally stumped after trying everything I can think of and read...

Any ideas as to what's causing it not to display all of the data and a possible get around will be greatly appreciated...

Thanks Chris

echo '&lt;html>'; echo '&lt;head>&lt;title> &lt;/title>'; echo '&lt;/head>'; echo '&lt;body>'; echo '&lt;form method=post action=xxx>'; echo '&lt;table border=5>'; $rows= mysql_fetch_array($result); echo '<tr>&lt;th>CIT Number&lt;/th>&lt;td>'; echo "&lt;input type=text disabled value=" . $rows['citnum'] . ">&lt;/td>&lt;/tr>"; echo '&lt;tr>&lt;th>Serial Number&lt;/th>&lt;td>'; echo "&lt;input type=text disabled value=" . $rows['sernum'] . ">&lt;/td>&lt;/tr>"; echo '&lt;tr>&lt;th>Move Date&lt;/th>&lt;td>'; echo "&lt;input type=text value=" . $rows['move_date_1'] . ">&lt;/td>&lt;/tr>"; echo '&lt;tr>&lt;th>From&lt;/th>&lt;td>'; echo "&lt;input type=text value=" . $rows[from_location_1] . ">&lt;/td>&lt;/tr>"; echo '&lt;tr>&lt;th>To&lt;/th>&lt;td>'; echo "&lt;input type=text value=" . $rows['to_location_1'] . ">&lt;/td>&lt;/tr>"; echo '&lt;tr>&lt;th>Comment&lt;/th>&lt;td>'; echo "&lt;input type=text value=" . $rows['comment_1'] . ">&lt;/td>&lt;/tr>"; echo '&lt;/td><td align="center">'; echo '&lt;/td>&lt;/tr>&lt;/table>'; echo '&lt;input type=submit value="Click To update">'; echo '&lt;/form>'; echo '&lt;/body>'; echo '&lt;/html>'; mysql_close($dbconnect); 
2
  • Chris Welcome to stackoverflow. You can make this a code block by pressing Ctrl+k. Also, what errors are reported? Commented Nov 9, 2010 at 16:04
  • Thank for the tip!!! There are no errors just that for the 2 variable mentioned are not show all of the data... Commented Nov 9, 2010 at 16:58

1 Answer 1

3

Your echo statements from the database do not have any quotes around the $rows from the database. Also you should escape values coming from the database

change lines like

echo "<input type=text value=" . $rows['comment_1'] . "></td></tr>"; 

to

echo "<input type=text value=\"" . htmlspecialchars($rows['comment_1']) . "\"></td></tr>"; 
Sign up to request clarification or add additional context in comments.

1 Comment

It worked!! Thanks to extra tips and the solution... I may have some other questions have I've read up on the htmlspecialchars() function!! Chris

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.