Jump to content

j.g.

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Everything posted by j.g.

  1. I guess I'm OK with that - I'm the Newbie here and am just following the way things were done before and I see the tags in the db when I query it.... OK, so this is where I'm posting the data in the header: <tr> <td style="padding:10px;" class="smtext"> <?php $query = "SELECT title, announcement_type_id FROM announcements " ."WHERE announcement_type_id = '0' " ."ORDER BY title"; $result = $db->query($query) or die("Invalid Query - Announcements Select"); while( $r = $db->fetch_row($result) ) { ?> <li> <?php echo ($r["title"]); echo "<BR>"; } ?> </li> <p></td> Can I still use nl2br here? And if so, how can I do that? Thanks! -j.g.
  2. Hello Board! I'm trying to implement a text box that will not require HTML, but will store the input into a mysql db with html tags; I think I can do this with the nl2br function - however, I'm not sure on what I need to do to get this to work. I've tried a couple of different implementations with no success to this point. :-\ So, here I am - asking the experts!! The input is being input into a text box: <td> <textarea rows="5" cols="34" name="title"><?php echo $title;?></textarea> </td> And input into my db (through either an INSERT or UPDATE stmt): if ( $operation == "Add" && !$error_msg) { if($url == "offsite") { $url = $offsite_url; $offsite_link = 1; } $query = "INSERT INTO announcements (title, url, announcement_type_id, offsite_link, post_date) " ."VALUES('".$db->clean($title)."', '".$db->clean($url)."', '".$db->clean($type_id)."', '" .".$db->clean($offsite_link)."', now() )"; $result = $db->query($query) or die("Invalid Query - announcements Add"); $announcement_id = $db->get_last_insert_id(); header("Location: announcements_updater.php?type_id=".$type_id); } elseif ( $announcement_id && $operation == "Update" && !$error_msg ) { if($url == "offsite") { $url = $offsite_url; $offsite_link = 1; } $query = "UPDATE announcements SET title = '".$db->clean($title)."', url = '".$db->clean($url)."', " ."offsite_link = '".$db->clean($offsite_link)."', last_update = now() " ."WHERE announcement_id = '".$db->clean($announcement_id)."'"; $result = $db->query($query) or die("Invalid Query - announcements Update"); header("Location: announcements_updater.php?type_id=".$type_id); } So, I don't want to require the user's to input HTML into the text box, however, I want to store it as HTML in the db and be able to retrieve it as HTML for display purposes... Thanks in advance for your time and expertise!! Please let me know if I can provide anymore information. Thanks much, -j.g.
  3. Thanks for the replies!! They were very helpful and instrumental in my successful implementation of the function and executing what I wanted to do!! Below is my final solution - hopefully it will help someone else in the future! //deletes the file from the server after the user clicks the 'Remove' link if(isset($_GET['delete_file'])) { unlink($DOCUMENT_ROOT.'/uploads/accounts/'.$_GET['delete_file']); //sets file_name field in db to 'blank' after deleting from server $file_update_query = "UPDATE address, users SET " ."file_name = '".$db->clean($POST[" "][" "])."' " ."WHERE users.user_id = '".$db->clean($current_user_id)."' " ."AND address.user_id = users.user_id " ."AND address.address_id = users.work_address_id"; $result_file_update = $db->query($file_update_query) or die("Error Deleting Company Logo"); } $file_query = "SELECT file_name FROM users, address WHERE users.user_id = '".$db->clean($current_user_id)."' " ." AND address.user_id = users.user_id" ." AND address.address_id = users.work_address_id"; $result_file = $db->query($file_query) or die("Error Getting Company Data"); while( $r = $db->fetch_row($result_file) ){ $filename = $r["file_name"]; } //if filename exists, display the filename & a 'Remove' link if ($filename != "") { echo $filename." <a href='company_edit.php?delete_file=".$filename."');\">Remove</a><br>"; echo "</span>"; } Thanks again!! -j.g.
  4. Hello All! I'm trying to implement the 'unlink' function to delete a file stored on the server; In this field it shows: Current Logo File: <fileName> Remove What I want, is for the user to be able to click on the 'Remove' link and have the file deleted from the server... Here is my code (that, unfortunately, is not working :-\ - or else, hence, I wouldn't be here): Current Logo File: <?php $file_query = "SELECT file_name FROM users, address WHERE users.user_id = '".$db->clean($current_user_id)."' " ." AND address.user_id = users.user_id" ." AND address.address_id = users.work_address_id"; $result_file = $db->query($file_query) or die("Error Getting Company Data"); while( $r = $db->fetch_row($result_file) ) { $filename = $r["file_name"]; } if ($filename != "") { echo $filename." <a href=unlink(/uploads/accounts/".$filename.");\">Remove</a><br>"; echo "</span>"; } ?> <br> '/uploads/accounts/' is the directory on the server where the file is stored. Any help and/or assistance that you could provide me would be greatly appreciated!! Thanks in advance for your time and expertise! -j.g.
  5. Thank you VERY much for the reply and the help!! That did it - just had to spread out my php tags... And, I apologize for the formatting of my posting...I realized I forgot to use the code tags after I had posted. Thanks again! -j.g.
  6. Hello List! I'm very new to php and am working on a form that is used by multiple pages of the same sight; however, for one of our pages, I don't want two of the fields to display if the user selects it. So, if the id=2, then don't show these two fields (or if id != 2, show them, as I'm actually coding it)... What I've tried to do is put an 'if' statement around my two <tr>'s for the two rows I do not want displayed (if the id does not = 2, then show them...): <h2> <?= htmlentities($current->getTitle(), ENT_QUOTES); ?> </h2> <form action='<?= $PHP_SELF; ?>' method='post' enctype='multipart/form-data'> <input type='hidden' name='id' value='<?= $current->getId(); ?>' /> <input type='hidden' name='parent' value='<?= htmlentities($parent_id, ENT_QUOTES); ?>' /> <table border="0" class='thin_table'> <tr> <td class='normal' valign='top'> Award </td> <td class='normal' valign='top'> <input type='text' maxlength='200' name='title' size='60' value='<?= htmlentities($current->getTitle(), ENT_QUOTES); ?>' title='Title'> </td> </tr> <tr> <td class='normal' valign='top'> Description </td> <td class='normal' valign='top'> <textarea name='data' rows='8' cols='60' title='News'><?= htmlentities($current->getData(), ENT_QUOTES); ?></textarea> </td> </tr> <? if ($current->getId() != 2) { <tr> <td class='normal' valign='top'> Sort Order </td> <td class='normal' valign='top'> <?= simple_sort_order_select('sortorder', $current->getSortOrder(), 25); > </td> </tr> <tr> <td class='normal' valign='top'> Visible </td> <td class='normal' valign='top'> <?= true_false_checkbox('visible', ($current->getVisible() == 1)); > </td> </tr> } ?> <tr> <td class='normal' valign='top' align='center' colspan='2'> <input type='button' value='Return To Listing' onClick="window.location='/admin/awards.php';"> <input type='submit' name='save' value='Save'> </td> </tr> </table> </form> But, when I do this and click on the link to this page, I'm getting a Parse error: "Parse error: syntax error, unexpected '<' in /award_edit.php on line 82" -- Line 82 is the first line after my opening bracket after the if statement, so the bolded <tr> above... Any thoughts or ideas on how I can go about fixing this would be greatly appreciated!
  7. Thanks for the link! There are a lot of great ideas there!
  8. Hello All! I've just accepted a position in which I'll be doing some PHP programming, and I'm looking for some suggestions on some good book(s) to help me get started. Looking for either PHP only or PHP and MySQL - whatever you've found helpful in the past! I've perused what's out on Amazon - but everyone thinks their book is the best, so I thought I'd come to the experts for some advice. Thanks for your time and help! Happy Wednesday! -jg
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.