Jump to content

php 4 to php 5 now problems


didgydont

Recommended Posts

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 ? error.jpg

  <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 &nbsp&nbsp (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>&nbsp Type</b></td>
        <td><b>&nbsp Shipping</b></td>
        <td><b>&nbsp Sell</b></td>
        <td><b>&nbsp Price Date &nbsp </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\">&nbsp $item</td>
    <td bgcolor=\"$row_color\">&nbsp $type</td>
    <td align=\"right\" bgcolor=\"$row_color\">&nbsp Free</td>
    <td align=\"right\" bgcolor=\"$row_color\">&nbsp \$$cost2</td>
    <td align=\"right\" bgcolor=\"$row_color\">&nbsp $daysold day(s) old </td>
    </tr>";}
      elseif  ($daysold <= 30){
    echo "<tr>
    <td bgcolor=\"$row_color\">&nbsp $item</td>
    <td bgcolor=\"$row_color\">&nbsp $type</td>
    <td align=\"right\" bgcolor=\"$row_color\">&nbsp \$$shipping2</td>
    <td align=\"right\" bgcolor=\"$row_color\">&nbsp \$$cost2</td>
    <td align=\"right\" bgcolor=\"$row_color\">&nbsp $daysold day(s) old </td>
    </tr>";}
    elseif  ($shipping2==0){echo "<tr>
    <td bgcolor=\"$row_color\">&nbsp $item</td>
    <td bgcolor=\"$row_color\">&nbsp $type</td>
    <td align=\"right\" bgcolor=\"$row_color\">&nbsp Free</td>
    <td align=\"right\" bgcolor=\"$row_color\" class=\"redtext\">&nbsp \$$cost2</td>
    <td align=\"right\" bgcolor=\"$row_color\">&nbsp $daysold day(s) old </td>
    </tr>";}

    else    echo "<tr>
    <td bgcolor=\"$row_color\">&nbsp $item</td>
    <td bgcolor=\"$row_color\">&nbsp $type</td>
    <td align=\"right\" bgcolor=\"$row_color\">&nbsp \$$shipping2</td>
    <td align=\"right\" bgcolor=\"$row_color\" class=\"redtext\">&nbsp \$$cost2</td>
    <td align=\"right\" bgcolor=\"$row_color\">&nbsp $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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.