There's a bug in this script, where if no comment is added to a post, it breaks the…
- User
There's a bug in this script, where if no comment is added to a post, it breaks the layout. Comments should be optional
.container { max-width: 800px; margin: 50px auto; padding: 20px; }
/* Headings / h1, h2 { color: #555; / Pure white for emphasis */ margin-top: 0; }
/* Forms / form { background: #1A1A1A; / Dark gray for form containers / padding: 25px; border-radius: 8px; margin-bottom: 20px; color: #E0E0E0; / Consistent light gray for form content */ }
/* Input Fields & Textareas / input[type="text"], textarea { width: 90%; padding: 12px; margin: 12px 0; border: none; background: #262626; / Slightly lighter black for input fields / color: #E0E0E0; / Light gray for input text */ border-radius: 6px; font-size: 16px; border: 1px solid #333; }
input[type="text"]:focus, textarea:focus { outline: none; background: #333333; /* Even lighter black for focus */ }
/* Textareas */ textarea { height: 120px; resize: none; }
/* Buttons / .btn { background-color: #0078D4; / Bright blue for primary actions / color: #FFFFFF; / White button text / padding: 12px 25px; border: none; border-radius: 6px; cursor: pointer; text-transform: uppercase; font-weight: bold; transition: background-color 0.3s ease, transform 0.2s ease; / Smooth hover effect */ }
.btn:hover { background-color: #005A9E; /* Darker blue for hover effect / transform: translateY(-2px); / Lift effect on hover */ }
/* Links / a { color: #0078D4; / Blue for links */ text-decoration: none; transition: color 0.3s ease; }
a:hover { color: #005A9E; /* Darker blue for hover interactions */ }
/* Tour List */ .tour-list { list-style: none; padding: 0; }
.tour-item { background-color: #1A1A1A; /* Slightly lighter dark gray for list items */ margin-bottom: 20px; padding: 20px; border-radius: 8px; text-align: left; }
.tour-item .date { font-size: 16px; font-weight: bold; color: #6CC644; /* Green for dates (positive emphasis) */ }
.tour-item .location { font-size: 16px; color: #0078D4; /* Bright blue for locations */ }
.tour-item .comments { font-size: 16px; color: #E0E0E0; /* Consistent gray for comments / white-space: pre-wrap; margin-top: 10px; line-height: 1.1; / Readable spacing */ }
/* Action Buttons / .tour-item .actions button { margin-top: 10px; display: inline-block; margin-right: 10px; background-color: #6CC644; / Green for action buttons (positive intent) / color: #0D0D0D; / Dark black text for contrast */ border: none; border-radius: 6px; padding: 10px 20px; cursor: pointer; transition: background-color 0.3s ease, transform 0.2s ease; }
.tour-item .actions button:hover { background-color: #4C9A31; /* Slightly darker green on hover Lift hover effect */ }
- Assistant
The script is designed to make comments optional for posts like tour dates. The layout breaks seem to relate to improper handling when comments are empty.
The issue likely arises when this block of HTML is output:
<div class="comments"><?php echo autoLink($tour['comments']); ?></div>Even when
commentsis missing or blank, the emptydivis rendered, potentially causing unexpected layout issues.Fix:
You need to conditionally output the
divfor comments only if there is a non-empty value for comments. Modify the code in the loop to check for empty comments as follows:Replace this block in the
foreachloop:<div class="comments"><?php echo autoLink($tour['comments']); ?></div> - User
There's still breakage if no comment is posted
- Assistant
- User
syntax error, unexpected identifier "comments", expecting "]" in /home/taco/Desktop/gypsy/edit.php on line 77
- Assistant
- User
Rewrite the script into one file
- Assistant
- User
- Assistant