didgydont Posted January 29, 2008 Share Posted January 29, 2008 hi all i had made a price list for work wich worked great but now its php 5 and i have it setup to post back to same form but now on first load because the post are empty it has error msg. does anyone know how to hide the error or work around it ? <html> <head> <title>Jennings Price List</title> <link rel="stylesheet" type="text/css" href="admin/site.css" /> </head> <?php include("toolbar.php"); $typesearch = "$_POST[typesearch]" ; $itemsearch = "$_POST[itemsearch]" ; echo "<h3>Shipping and GST included in sell price.</h3><br />"; echo " <table border=\"0\" cellpadding=\"5\" cellspacing=\"0\"> <form action=\"index.php\" method=\"post\"> <tr><td>Item Description:</td><td><input type=\"text\" name=\"itemsearch\" value=\"$itemsearch\" class=\"TEXTB\" /></td> <td>Type: </td><td><select type=\"text\" name=\"typesearch\" class=\"SELECTA\" /> <option value=\"$typesearch\">$typesearch    (current)</option> <option value=\"All Items\">All Items</option>"; include("admin/type.php"); echo "</select></td> <td></td><td><input type=\"submit\" VALUE=\"search\" /></td></tr> </form></table><br /><br />"; // Begin your table outside of the array echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\"> <tr> <td><b>Item</b></td> <td><b>  Type</b></td> <td><b>  Shipping</b></td> <td><b>  Sell</b></td> <td><b>  Price Date   </b></td> </tr>"; // Define your colors for the alternating rows $color1 = "#E3E4FA"; $color2 = "#C8BBBE"; $row_count = 0; // Perform an statndard SQL query: if (eregi("^All Items$", $typesearch)){ $result = mysql_query("SELECT * FROM products WHERE item LIKE '%$_POST[itemsearch]%' ORDER BY type"); } elseif (empty ($typesearch)){ $result = mysql_query("SELECT * FROM products WHERE item LIKE '%$itemsearch%' ORDER BY type"); } else { $result = mysql_query("SELECT * FROM products WHERE type='$typesearch' and item LIKE '%$_POST[itemsearch]%' ORDER BY cost"); } // We are going to use the "$row" method for this query. This is just my preference. while($row = mysql_fetch_array($result)) { $cost = $row['cost']; $markup = $row['markup']; $shipping = $row['shipping']; if ($markup==0){$sell = ($cost * 1.2 * 1.1 + $shipping);} else {$sell = (($cost + $markup) * 1.1 + $shipping);} $cost3 = number_format ($sell,2); $cost2 = roundup ($cost3,0); $shipping2 = number_format ($shipping,0); $item = $row['item']; $supplier = $row['supplier']; $type = $row['type']; $dandt = date('Y-m-d'); $pricedate = $row['pricedate']; $timestamp = strtotime($pricedate); $formatted_date = date('F-d-Y', $timestamp); $daysold = round((strtotime($dandt) - strtotime($pricedate))/(24*60*60),0); /* Now we do this small line which is basically going to tell PHP to alternate the colors between the two colors we defined above. */ $row_color = ($row_count % 2) ? $color1 : $color2; // Echo your table row and table data that you want to be looped over and over here. if (($daysold <= 30) AND ($shipping2==0)){ echo "<tr> <td bgcolor=\"$row_color\">  $item</td> <td bgcolor=\"$row_color\">  $type</td> <td align=\"right\" bgcolor=\"$row_color\">  Free</td> <td align=\"right\" bgcolor=\"$row_color\">  \$$cost2</td> <td align=\"right\" bgcolor=\"$row_color\">  $daysold day(s) old </td> </tr>";} elseif ($daysold <= 30){ echo "<tr> <td bgcolor=\"$row_color\">  $item</td> <td bgcolor=\"$row_color\">  $type</td> <td align=\"right\" bgcolor=\"$row_color\">  \$$shipping2</td> <td align=\"right\" bgcolor=\"$row_color\">  \$$cost2</td> <td align=\"right\" bgcolor=\"$row_color\">  $daysold day(s) old </td> </tr>";} elseif ($shipping2==0){echo "<tr> <td bgcolor=\"$row_color\">  $item</td> <td bgcolor=\"$row_color\">  $type</td> <td align=\"right\" bgcolor=\"$row_color\">  Free</td> <td align=\"right\" bgcolor=\"$row_color\" class=\"redtext\">  \$$cost2</td> <td align=\"right\" bgcolor=\"$row_color\">  $daysold day(s) old </td> </tr>";} else echo "<tr> <td bgcolor=\"$row_color\">  $item</td> <td bgcolor=\"$row_color\">  $type</td> <td align=\"right\" bgcolor=\"$row_color\">  \$$shipping2</td> <td align=\"right\" bgcolor=\"$row_color\" class=\"redtext\">  \$$cost2</td> <td align=\"right\" bgcolor=\"$row_color\">  $daysold day(s) old </td> </tr>"; // Add 1 to the row count $row_count++; } // Close out your table. echo "</table>"; mysql_close($con); ?> <br /><br /> </html> Quote Link to comment https://forums.phpfreaks.com/topic/88362-php-4-to-php-5-now-problems/ Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 you'll have to change your php.ini setting and turn off notice displays error_reporting = E_ALL && ~E_NOTICE or change your code too $typesearch = (isset($_POST[typesearch])) ? $_POST[typesearch] : "" ; $itemsearch = (isset($_POST[itemsearch])) ? $_POST[itemsearch]: "" ; or $typesearch = @$_POST[typesearch]; $itemsearch = @$_POST[itemsearch]; an "@" is to suppress errors Quote Link to comment https://forums.phpfreaks.com/topic/88362-php-4-to-php-5-now-problems/#findComment-452201 Share on other sites More sharing options...
didgydont Posted January 29, 2008 Author Share Posted January 29, 2008 thank you i went with the @ option works great again there had been other quirks but this one had me stumpped thank you again Quote Link to comment https://forums.phpfreaks.com/topic/88362-php-4-to-php-5-now-problems/#findComment-452216 Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 Your welcome.. glad to be of help.. however a word of caution you can use the "@" to suppress errors but sometimes if you use it on functions it becomes hard to debug, it suppresses all errors including fatal errors so you might not know whats wrong with your code Quote Link to comment https://forums.phpfreaks.com/topic/88362-php-4-to-php-5-now-problems/#findComment-452219 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.