Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by lauralee

  1. Below is the code with the suggested changes. Still no UPDATE takes place. I use the same code to UPDATE another database table (with different field names) and it works. So I must be missing something here. if (isset($_POST['action']) and $_POST['action'] =='Edit'){ $fee_id = $_POST['fee_id']; $fee_title = $_POST['fee_title']; $fee_name = $_POST['fee_name'];$fee_description = $_POST['fee_description']; $fee_amount = $_POST['fee_amount']; $fee_order = $_POST['fee_order'];$fee_title= mysql_real_escape_string($fee_title);$fee_description= mysql_real_escape_string($fee_description); $fee_name= mysql_real_escape_string($fee_name);$fee_order= mysql_real_escape_string($fee_order);$sql = "UPDATE fee_schedule SET fee_id = '$fee_id', fee_title = '$fee_title', fee_name = '$fee_name', fee_description = '$fee_description', fee_amount = '$fee_amount', fee_order = '$fee_order' WHERE fee_id ='$fee_id'";ini_set('display_errors', 1);error_reporting(E_ALL); if (!mysql_query($sql)) { echo '<p>Error updating fee schedule: ' . mysql_error() . '</p>'; exit(); } }
  2. I made the changes that you suggested with no result. I still receive no error, and no update takes place.
  3. Thanks. But my problem is that the coding I use on one page works fine, but the other one doesn't, although they seem to be identical, just the names are different. Below is the update that works. Can you find a difference in the one I posted earlier that would explain why this one works and the other one doesn't? I can't find the problem in the UPDATE code that I posted earlier. if (isset($_POST['action']) and $_POST['action'] =='Edit'){ $contacts_id = $_POST['contacts_id']; $contacts_first_name = $_POST['contacts_first_name']; $contacts_last_name = $_POST['contacts_last_name'];$contacts_department = $_POST['contacts_department'];$contacts_title = $_POST['contacts_title']; $contacts_email = $_POST['contacts_email']; $contacts_order = $_POST['contacts_order']; $publish = $_POST['publish']; $contacts_first_name= mysql_real_escape_string($contacts_first_name); $contacts_last_name= mysql_real_escape_string($contacts_last_name); $contacts_email= mysql_real_escape_string($contacts_email); $sql = "UPDATE contacts SET contacts_first_name = '$contacts_first_name', contacts_last_name = '$contacts_last_name', contacts_department = '$contacts_department', contacts_title = '$contacts_title', contacts_email = '$contacts_email', contacts_order = '$contacts_order', publish = '$publish' WHERE contacts_id ='$contacts_id'"; if (!@mysql_query($sql)) { echo '<p>Error updating contacts: ' . mysql_error() . '</p>'; exit(); } }
  4. Can anyone find the problem with my code? I have used this code to update a table of contact information in my database, but for some reason, this same structure doesn't work for updating a fee schedule table. I don't get any kind of error, it just won't update the table. echo '<form action=" " method="post">';echo '<table class="contactlist"><tr><caption>FEE SCHEDULE</caption></tr><tr><th>FOR:</th><th>TYPE<th>DESCRIPTION</th><th>AMOUNT</th><th>ORDER</th></tr>'; while ($rw = @mysql_fetch_array($rslt)) {echo '<input type="hidden" name="fee_id" value = "' . $rw['fee_id'] . '" />';echo '<tr><td><input type="text" name="fee_title" value = "' . $rw['fee_title'] . '" size="35" /></td>';echo '<td><input type="text" name="fee_name" rows="5" cols="20" value = "' . htmlspecialchars($rw['fee_name'], ENT_QUOTES, 'UTF-8') . '" size="30" /></td>';echo '<td><input type="text" name="fee_description" value = "' . htmlspecialchars($rw['fee_description'], ENT_QUOTES, 'UTF-8') . '" size="20" /></td>';echo '<td><input type="text" name="fee_amount" value="' . $rw['fee_amount'] . '" size="25" /></td>';echo '<td><input type="text" name="fee_order" value="' . $rw['fee_order'] . '" size="5" /></td>';echo '<td><input type="submit" name="action" value="Edit" /></td></tr>';echo '</form>';} echo '</table>'; if (isset($_POST['action']) and $_POST['action'] =='Edit'){ $fee_id = $_POST['fee_id']; $fee_title = $_POST['fee_title']; $fee_name = $_POST['fee_name'];$fee_description = $_POST['fee_description']; $fee_amount = $_POST['fee_amount']; $fee_order = $_POST['fee_order'];$fee_title= mysql_real_escape_string($fee_title);$fee_description= mysql_real_escape_string($fee_description); $fee_name= mysql_real_escape_string($fee_name);$fee_order= mysql_real_escape_string($fee_order);$sql = "UPDATE fee_schedule SET fee_id = '$fee_id', fee_title = '$fee_title', fee_name = '$fee_name', fee_description = '$fee_description', fee_amount = '$fee_amount', fee_order = '$fee_order' WHERE fee_id ='$fee_id'"; if (!@mysql_query($sql)) { echo '<p>Error updating fee schedule: ' . mysql_error() . '</p>'; exit(); } }
  5. But the form fields are populated with the text from the database table that are to be edited, they are not empty fields where text is to be entered, so I can't do an UPDATE until after the form is displayed with the populated fields can I?
  6. I added: echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">'; but it still doesn't show the changes until I refresh the page. I've also changed the form action to "http://www.conservfirst.com/admin/edit_family.php" but the changes still don't show up until I refresh the page. Any other suggestions?
  7. I have an administrator's page set up to update table contents in my database. It displays each field in a form using a table. Whenever I click on the submit button, I have to refresh the page to see the changes. But I want the changes to display immediately after clicking the submit button. I added header('Location: . ');exit(); to the code but I get the following error Warning: Cannot modify header information - headers already sent by (output started at /home/conservf/public_html/admin/edit_family.php:25) in /home/conservf/public_html/admin/edit_family.php on line 101 Below is the code - How can I fix this so when I edit the information in the table, it displays immediately? <body><div id="wrapper1"><a name="Top"></a><h1>Edit Family Names</h1><div class="textbox"><h4>Today is -<?php$my_t=getdate(date("U"));print("$my_t[weekday], $my_t[month] $my_t[mday], $my_t[year]<br />");?></h4><p><a href="<?php echo $_SERVER['PHP_SELF']; ?>?logout=1" >Logout</a></p><p><a href="http://www.conservfirst.com/admin/">Return to Admin Page</a></p><p><a href="edit_family.php">Refresh page</a></p><h4><a href="?addfamily">Add a new family</a></h4><?phpif (isset($_GET['addfamily'])){ include '/home/conservf/public_html/includes/addfamilyform.inc.html.php'; exit(); } ?></div><?php include '/home/conservf/public_html/includes/connection.inc.html.php'; ?><?php include '/home/conservf/public_html/includes/magicq.inc.html.php'; ?><?php include '/home/conservf/public_html/includes/helpers.inc.html.php'; ?><?php$sql = "SELECT * FROM family1 ORDER BY family_name"; $result = @mysql_query($sql); if (!result) { $error = 'Error fetching information'; exit();} echo '<table class="building"><tr><caption>Edit Family Names</caption</tr><tr><th>FAMILY</th><th>CATEGORY</th><th>DESCRIPTION</th><th>Item<br />order</th><th>In-<br />active</th></tr>'; while ($row = mysql_fetch_array($result)) { echo '<form action="http://www.conservfirst.com/admin/edit_family.php" method="post">';echo '<input type="hidden" name="familyid" value = "' . $row['familyid'] . '" />';echo '<td><input type="text" name="family_name" value = "' . htmlspecialchars($row['family_name'], ENT_QUOTES, 'UTF-8') . '" size="15" /></td>';echo '<td><input type="text" name="category" value = "' . htmlspecialchars($row['category'], ENT_QUOTES, 'UTF-8') . '" size="25" /></td>'; echo '<td><input type="text" name = "familydescription" value ="' . htmlspecialchars($row['familydescription'], ENT_QUOTES, 'UTF-8') . '" size="80" /></td>'; echo '<td><input type="text" name="item_order" value = "' . htmlspecialchars($row['item_order'], ENT_QUOTES, 'UTF-8') . '" size="2" /></td>'; echo '<td><input type="text" name="inactive" value = "' . htmlspecialchars($row['inactive'], ENT_QUOTES, 'UTF-8') . '" size="2" /></td>'; echo '<td><input type="submit" name="action" value="Edit" /></td></tr>'; if (isset($_POST['familyid'])) $familyid = $_POST['familyid']; $family_name = mysql_real_escape_string($_POST['family_name']); $category = mysql_real_escape_string($_POST['category']);$familydescription = mysql_real_escape_string($_POST['familydescription']); $inactive = $_POST['inactive']; $item_order = $_POST['item_order']; $sql = "UPDATE family1 SET family_name = '$family_name', category = '$category', familydescription = '$familydescription', inactive = '$inactive', item_order = '$item_order' WHERE familyid ='$familyid'"; if (!@mysql_query($sql)) { echo '<p>Error updating family1: ' . mysql_error() . '</p>'; exit(); } header('Location: . '); exit(); echo '</form>'; }echo '</table>';?></body>
  8. I am using a loop with a form to show products in a table that can be edited. When I click the "edit" button to post the update, I want the changes to show up immediately in the form. Right now, I have to refresh the page to see the changes. How can I get the changes to show immediately after clicking on the "edit" (submit) button? My form for editing product is shown below. echo '<a name="Building Envelope Products"></a>';$sql = "SELECT * FROM products WHERE category='Building Envelope Products' order by id"; $result = @mysql_query($sql); if (!result) { $error = 'Error fetching information';exit();} echo '<table class="building"><tr><caption>Edit Building Envelope Products</caption</tr><tr><th>ID</th><th>CATEGORY</th><th>FAMILY</th><th>FAMILY ID</th><th>SBFM</th><th>NAME</th><th>DESCRIPTION</th><th>COLOR</th><th>WT</th><th>PRICE</th><th>INACT</th><th>PayPal #</th><th>EDIT</th></tr>'; while ($row = mysql_fetch_array($result)) { echo '<form action=" " method="post">'; echo '<tr><td><input type="text" name="id" value = "' . $row['id'] . '" size="9" /></td>'; echo '<td><input type="text" name="category" value = "' . htmlspecialchars($row['category'], ENT_QUOTES, 'UTF-8') . '" size="15" /></td>'; echo '<td><input type="text" name="familyname" value = "' . htmlspecialchars($row['familyname'], ENT_QUOTES, 'UTF-8') . '" size="10" /></td>'; echo '<td><input type="text" name="family_id" value = "' . htmlspecialchars($row['family_id'], ENT_QUOTES, 'UTF-8') . '" size="10" /></td>'; echo '<td><input type="text" name="subfamily_identifier" value = "' . htmlspecialchars($row['subfamily_identifier'], ENT_QUOTES, 'UTF-8') . '" size="5" /></td>'; echo '<td><input type="text" name="name" value = "' . htmlspecialchars($row['name'], ENT_QUOTES, 'UTF-8') . '" size="15" /></td>'; echo '<td><input type="text" name="description" value = "' . htmlspecialchars($row['description'], ENT_QUOTES, 'UTF-8') . '" size="45" /></td>'; echo '<td><input type="text" name="color" value = "' . htmlspecialchars($row['color'], ENT_QUOTES, 'UTF-8') . '" size="5" /></td>'; echo '<td><input type="text" name="weight" value = "' . htmlspecialchars($row['weight'], ENT_QUOTES, 'UTF-8') . '" size="3" /></td>'; echo '<td><input type="text" name="list_price" value = "' . htmlspecialchars($row['list_price'], ENT_QUOTES, 'UTF-8') . '" size="3" /></td>'; echo '<td><input type="text" name="inactive" value = "' . htmlspecialchars($row['inactive'], ENT_QUOTES, 'UTF-8') . '" size="1" /></td>'; echo '<td><input type="text" name="button" value = "' . htmlspecialchars($row['button'], ENT_QUOTES, 'UTF-8') . '" size="15" /></td>'; echo '<td><input type="submit" name="action" value="Edit" /></td>'; if (isset($_POST['id']))$id = $_POST['id']; $familyname = $_POST['familyname']; $subfamily_identifier = $_POST['subfamily_identifier']; $name = $_POST['name']; $description = $_POST['description']; $color = $_POST['color']; $weight = $_POST['weight']; $list_price = $_POST['list_price']; $inactive = $_POST['inactive']; $button = $_POST['button']; $description = mysql_real_escape_string($description); $familyname = mysql_real_escape_string($familyname); $subfamily_identifier = mysql_real_escape_string($subfamily_identifier); $name = mysql_real_escape_string($name); $color = mysql_real_escape_string($color); $weight = mysql_real_escape_string($weight); $list_price = mysql_real_escape_string($list_price); $inactive = mysql_real_escape_string($inactive); $button = mysql_real_escape_string($button); $sql = "UPDATE products SET id = '$id', familyname = '$familyname', subfamily_identifier='$subfamily_identifier', name = '$name', description = '$description', color = '$color', weight = '$weight', list_price = '$list_price', inactive = '$inactive', button = '$button' WHERE id ='$id'"; if (!@mysql_query($sql)) { echo '<p>Error updating product: ' . mysql_error() . '</p>'; exit(); } echo '</form>';}echo '</table>';
  9. Currently in my code I select the current month and future months to be shown on the calendar. I want to be able to have only the current month and future months shown automatically using the date function. Below is my code. How do I change the WHERE mo_id>09 in the code so that I don't have to change it manually every month and the only the current month and future months will display, not all of the month's names? $sql = @mysql_query('SELECT mo_id, month_name FROM month WHERE mo_id>09 ORDER BY mo_id'); if (!$sql) {exit('<p>Error performing query: ' . mysql_error() . '</p>');}while ($mos = mysql_fetch_array($sql)) { echo '<h2>' . $mos['month_name'] . '</h2><br />'; $items = @mysql_query('SELECT *FROM calendar WHERE mo ="' . $mos['month_name'] . '" OR "' . $mos['dt'] . '" ORDER BY dt, am_pm, hr, min'); if (!$items) {exit('<p>Error performing query: ' . mysql_error() . '</p>');}while ($each = mysql_fetch_array($items)) {echo '<p><em>' . $each['mo'] . ' ' . $each['dt'] . ' </em>' . $each['hr'] . ':' . $each['min'] . ' ' . $each['am_pm'] . ' - <span>' . $each['location'] . ' - ' . $each['title'] . '</span> - ' . $each['event'] . '</p>';}}?>
  10. I have a membership table that includes a field for the date that a membership was added. I want to be able to automatically sort the table by those memberships that have expired after one year from the date the membership was added. Below is the code that lists the members followed by the date of the membership. while ($row = @mysql_fetch_array($result)){ echo '<div class="memberdetails"><span class="second">' . $row['member_name'] . '</span> - ' . $row['membership_date'] . '<br />'; } I'm not sure how to use the ADDDATE function. Please give me a sample of code that would provide an expiration date that is one year after the membership_date.
  11. lauralee


    When you set up your website on a server you used a username and a password. Place them in your code where indicated below. $con = mysql_connect("localhost","username","password");
  12. Actually, the filename does have the .jpg extension. I just didn't type it in correctly in my previous response. So, I'm still stuck on this one.
  13. This may be too simple for what you are doing, but I have used the following code in a form to show the list of categories from the database category table in order to select one and insert it into a membership table in the database. Once the form is submitted, the information is inserted using INSERT INTO. $cat = @mysql_query('SELECT category_name, category_id FROM category ORDER BY category_name'); if (!$cat) { exit( '<p>Unable to obtain categories from the database.</p>'); }<h3>Select one category from drop-down list</h3><select name="category" size="1"> <option selected value="">Select Category</option><?php while ($row_ct = mysql_fetch_array($cat)) {$category_name = $row_ct['category_name']; echo "<option value='$category_name'>$category_name</option>\n"; } ?> </select><br />
  14. I found that the problem was actually in the css code. In the li li code I replaced padding:.2em; with 0 and the ghost effect disappeared.
  15. I have set up a drop down menu using only CSS that looks like a manilla file folder tab and works great in Mozilla Firefox, but in IE a partial tab to the left of the first tab appears thereby making the navigation bar look bad, and overruns the space allotted. I remember reading something about a ghost effect in IE that shows up sometimes, but I don't remember what the fix is. How can I get rid of that ghost li element in IE?Below is my navigation code:<ul id="nav"> <li><a href="http://www.raton.info.com/">Home</a></li> <li><a href="http://www.raton.info.com/about_us">About Us</a></li><li><div> <a href="http://www.raton.info.com/our_community/">Our Community</a></div> <ul class="none"> <li><a href="/art_culture">Arts & Culture</a></li> <li><a href="/business/">Business</a></li> <li><a href="/dining/">Dining</a></li> <li><a href="/education/">Education</a></li> <li><a href="/health/">Health Services</a></li> <li><a href="/real_estate/">Real Estate</a></li> <li><a href="/outdoor_recreation/">Outdoor Recreation</a></li> </ul> </li> <li> <div><a href="/area_attractions/">Area Attractions</a></div> <ul class="none"> <li><a href="/capulin/">Capulin Volcano National Monument</a></li> <li><a href="/nra_whittington/">NRA Whittington Center</a></li> <li><a href="/aquatic_center/">Raton Aquatic Center</a></li> <li><a href="/native_garden/">Santa Fe Trail Native Plant Garden</a></li> <li><a href="/sugarite/">Sugarite Canyon State Park</a></li> </ul> </li> <li><a href="/links/">Links</a></li></ul>
  16. Well, here is another nested loop problem on the same code that I've been working on. Now I want to show those products of the same size with different colors only once with the submit buttons for each color listed below the product description. Can I use another INNER JOIN with another while loop that will show only one size with the available colors listed below the product?Or should I try using an If statement to filter the size then the colors?The entire code I have now is below - but it still lists each product without showing a color submit button below each product. I'm not sure how to filter the sizes so that the product description shows only once for each size, then lists the color submit buttons below. Suggestions?$result = @mysql_query('SELECT * FROM family1 WHERE inactive=" "');if (!$result) {exit('<p>Error performing query: ' .mysql_error() . '</p>');}while ($row = mysql_fetch_array($result)){echo '<div class="product-b-1">';echo'<p><img class="products" src="/images/products/' . $row['family_name'] . '.jpg" alt="' . $row['family_name'] . '"></img><span>' . $row['family_name'] . '</span></p>';echo ' <p>' . bbcodeout($row['familydescription']) . '</p>';echo '</div>';$prods = @mysql_query('SELECT * FROM products INNER JOIN family1 ON family1.familyid = products.family_id WHERE familyid="' . $row['familyid'] . '" ORDER BY products.id');if (!$prods) {exit('<p>Error performing query: ' .mysql_error() . '</p>');}while ($typ = mysql_fetch_array($prods)){echo '<div class="product-b-1">';echo '<div class="pricebox">' . '$ ' . $typ['list_price'] . '</div><div class="productboxcolor">' . $typ['size'] . '</div>';echo '<div class="buttonbox"><form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">';echo '<input type="hidden" name="cmd" value="_s-xclick">';echo '<input type="hidden" name="hosted_button_id" value="' . $typ['button'] . '">';echo '<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"></form></div>';echo'<p><img class="products" src="/images/products/' . $typ['id'] . '.jpg" alt="' . $typ['id'] . '"></img><span>' . $typ['id'] . '</span></p>';echo ' <p>' . bbcodeout($typ['description']) . '<br /></p>';echo '</div>';}$prod_color = @mysql_query('SELECT color FROM products INNER JOIN colors ON colors.color_name=products.color WHERE color_name = "' . $typ['color'] . '" ORDER BY colors.color_name');if (!$prod_color) {exit('<p>Error performing color query: ' .mysql_error() . '</p>');}while ($clr = mysql_fetch_array($prod_color)){echo '<form>';echo '<div class="buybox">';echo '<input type="radio" name="' . $clr['color'] . '" value="' . $clr['color'] . '" id="' . $clr['color'] . '" /> <label>' . $clr['color'] . '</label><br />';echo '<div class="buttonbox">Buy</div></div>';echo '</form>';echo '</div>';echo '</div>';}}
  17. That is exactly what I do when I hit a problem that I can't solve. I use the forum and have always had great results. Thanks to all of you experts for being there and giving of your time to help.
  18. Thanks. I've checked out the manual while learning PHP, but sometimes it is difficult to understand because I don't have enough knowledge of the subject to be able to use what it says.
  19. Well, well, well here it is:$prods = @mysql_query('SELECT * FROM products INNER JOIN family1 ON family1.familyid = products.family_id WHERE familyid="' . $row['familyid'] . '" ORDER BY products.id');The problem was that I needed the double quotes before the single quote and after the single quote because of the . variable $row['familyid']Thanks for all of the suggestions. I suddenly saw it after thescientist mentioned the variable aspect. The double quotes weren't needed, but because it would normally be written familyid = " ", I needed to add familyid="' . $row['familyid'] . '" the variable inside the double quotes for a string.Thanks, again for helping me work through this!I'm now working on another related, very similar nested loop problem. I'll be back if I can't figure it out on my own.
  20. I have moved things around, added single quotes, double quotes and dots in a variety of places but nothing has worked so far. I know this can't be that complicated. I must be overlooking something......Should be able to order the results. Any other suggestions?
  21. Sorry, tried that one too and got this:Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/conservf/public_html/building_products/1indextest.php on line 69
  22. When I try that, the page shows the first family item, then the following error:"error performing query: "
  23. That's where I had tried it to begin with, but I get the following error:Parse error: syntax error, unexpected T_IF in /home/conservf/public_html/building_products/1indextest.php on line 70Then I tried putting double quotes here: ("SELECT........") and got this error:Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/conservf/public_html/building_products/1indextest.php on line 69So, I tried placing the ORDER BY in different places in the code, but with no luck. I keep getting the errors.
  24. Okay, now I want the results to ORDER BY a particular field, but I get errors no matter where I place the ORDER BY. Where do I put it so I don't get errors? $prods = @mysql_query('SELECT * FROM products INNER JOIN family1 ON family1.familyid = products.family_id WHERE familyid='. $row['familyid']); And why does the code below work without the ' before the closing parenthesis at the end? It seems like there should be ('SELECT.......... ')$prods = @mysql_query('SELECT * FROM products ORDER BY id INNER JOIN family1 ON family1.familyid = products.family_id WHERE familyid='. $row['familyid']);
  25. Thanks so much! It works. Now, it becomes a little more complicated because I need to have each product displayed with different sizes and colors if they have different size and color. Again, I'll work on this myself and will ask for help if I get stuck and can't find a solution.I love this forum!!! It is so helpful and no one is condescending with us newbies who are trying to learn PHP. Thanks to ALL!
  • Create New...