Jump to content

Recommended Posts

hi all im trying to echo the value "Seagate Mentus 2.5" 160Gig 5400RPM" into a form i can submit it ok using php i can even echo it but when trying to echo it as a value into a form it only loads "Seagate Mentus 2.5" i tried entering into the database as "Seagate Mentus 2.5" 160Gig 5400RPM" same thing any ideas ?

  <html>
  <head>
  <title>Price List</title>
  <link rel="stylesheet" type="text/css" href="site.css" />
  </head>
                 <?php
                include("connect.php");
                 include("toolbar.php");


  $uid = @"$_POST[uid]";
  $supplier = @"$_POST[supplier]";
  $type = @"$_POST[type]";
  $item = @"$_POST[item]";
  $type = @"$_POST[type]";
  $cost6 = @"$_POST[cost]";
  if(eregi("^([.]+[0-9]{2})$", $cost6)){
      $cost = preg_replace("/(.+[0-9]{2})/", "0$1", $cost6);}
      else {$cost = $cost6;}
  $shipping = @"$_POST[shipping]";
  $markup = @"$_POST[markup]";

  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);
           //$cost2 = number_format ($sell,2);
    $cost2 = ceil($sell);

  $dandt = date('Y-m-d');



$result = mysql_query("SELECT * FROM products WHERE uid='$uid'");
while($row = mysql_fetch_array($result)) {
      
    if(empty($cost)){
    $cost5 = $row['cost'];}
    else {$cost5 = $cost;}
    if(empty($item)){
    $item5 = $row['item'];}
    else {$item5 = $item;}
    if(empty($supplier)){
    $supplier5 = $row['supplier'];}
    else {$supplier5 = $supplier;}
    if(empty($shipping)){
    $shipping5 = $row['shipping'];}
    else {$shipping5 = $shipping;}
    if(empty($markup)){
    $markup5 = $row['markup'];}
    else {$markup5 = $markup;}
    $type5 = $row['type'];

  echo "$item5";
echo  "<br /><table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">
<tr><td><form action=\"\" method=\"post\">
<input type=\"hidden\" name=\"delit\" value=\"$uid\" class=\"TEXTB\" />
<input type=\"submit\" VALUE=\"Remove\" />
</form>
</td><td>&nbsp</td><td><h3>OR Update Item</h3></td></tr>
</table><br />";


echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">

<form action=\"\" method=\"post\">
<tr><td></td><td><input type=\"hidden\" name=\"uid\" value=\"$uid\" class=\"TEXTB\" /></td></tr>
<tr><td>Item Description:</td><td><input type=\"text\" name=\"item\" value=\"$item5\" class=\"TEXTB\" /></td></tr>
<tr><td>Ex Tax $: </td><td><input type=\"text\" name=\"cost\" value=\"$cost5\" class=\"TEXTB\" /></td></tr>
<tr><td>Markup $: </td><td><input type=\"text\" name=\"markup\" value=\"$markup5\" class=\"TEXTB\" /></td></tr>
<tr><td>Shipping $: </td><td><input type=\"text\" name=\"shipping\" value=\"$shipping5\" class=\"TEXTB\" /></td></tr>
<tr><td>Type: </td><td><select type=\"text\" name=\"type\" class=\"SELECTA\" />
<option value=\"$type5\">$type5 &nbsp&nbsp (current)</option>";
include("type.php");
echo "</select></td></tr>
<tr><td>Supplier: </td><td><select type=\"text\" name=\"supplier\" class=\"SELECTA\" />
<option value=\"$supplier5\">$supplier5 &nbsp&nbsp (current)</option>";
include("supplier.php");
echo "</select></td></tr>
<tr><td></td><td><input type=\"submit\" VALUE=\"Update Item\" /></td></tr>
</form></table><br /><br />";

}
$delit = @"$_POST[delit]";
mysql_query("DELETE FROM products WHERE uid='$delit'");

  if(eregi("^[0-9]{1,10}$", $delit)) {

  die('<br /><b>Item has been deleted</b><br />' . mysql_error());
}

else {
    echo "";
}


//Description Verification

if (empty ($item)){
    die('<b>Dont forget to select the supplier</b><br />' . mysql_error());
}
else {
    echo "<b>Item Description:</b> Okay.<br />";
}

//Cost Verification

  if(eregi("^[0-9]+(.[0-9]{2})*$", $cost)) {

  echo "<b>Ex Tax Price:</b> Okay.<br />";
}
elseif (empty ($cost)){
    die('<b>We cant be just givin shit away..</b><br />' . mysql_error());
}

else {
    die('<b>Invalid Cost $:</b><br />' . mysql_error());
}

//Markup Verification

  if(eregi("^[0-9]+(.[0-9]{2})*$", $markup)) {

  echo "<b>Markup Price:</b> Okay.<br />";
}
elseif (empty ($markup)){
    echo "<b>Markup Price:</b> None.<br />";
}

else {
    die('<b>Invalid Markup $$$:</b><br />' . mysql_error());
}

//Shipping Verification

  if(eregi("^[0-9]+(.[0-9]{2})*$", $shipping)) {

  echo "<b>Shipping Price:</b> Okay.<br />";
}
elseif (empty ($shipping)){
    echo "<b>Shipping Price:</b> Free.<br />";
}

else {
    die('<b>Invalid Shipping $$$:</b><br />' . mysql_error());
}

//type Verification


if (eregi("^NSEL$", $type)){
    die('<b>What type of item is it ?? </b><br />' . mysql_error());
}
else {
    echo "<b>Type:</b> Okay.<br />";
}

//supplier Verification


if (eregi("^NSEL$", $supplier)){
    die('<b>You forgot to select a supplier </b><br />' . mysql_error());
}
else {
    echo "<b>Supplier:</b> Okay.<br />";
}




mysql_query("UPDATE products SET item = '$item'
WHERE uid = '$uid'");
mysql_query("UPDATE products SET cost = '$cost'
WHERE uid = '$uid'");
mysql_query("UPDATE products SET shipping = '$shipping'
WHERE uid = '$uid'");
mysql_query("UPDATE products SET type = '$type'
WHERE uid = '$uid'");
mysql_query("UPDATE products SET supplier = '$supplier'
WHERE uid = '$uid'");
mysql_query("UPDATE products SET pricedate = '$dandt'
WHERE uid = '$uid'");
mysql_query("UPDATE products SET markup = '$markup'
WHERE uid = '$uid'");


echo "<br />the new sell price is $$cost2<br /><br />";
echo "1 record updated";mysql_close($con) ;

?>
</html>

Link to comment
https://forums.phpfreaks.com/topic/96663-solved-echo-form-value-containing-symbol/
Share on other sites

There is a very simple explanation to this. Quotes surround strings, you have an open quote and a closing quote.

 

I think you can see from this why your echo is not working. For your example use double quotes for the whole string (one at each end) and single quotes around the quoted item within the string.

i tried but it gave me an error

this is the broken part i can echo the string fine in other areas just not the from

echo ""<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">

<form action=\"\" method=\"post\">
<tr><td></td><td><input type=\"hidden\" name=\"uid\" value=\"$uid\" class=\"TEXTB\" /></td></tr>
<tr><td>Item Description:</td><td><input type=\"text\" name=\"item\" value=\"$item5\" class=\"TEXTB\" /></td></tr>
<tr><td>Ex Tax $: </td><td><input type=\"text\" name=\"cost\" value=\"$cost5\" class=\"TEXTB\" /></td></tr>
<tr><td>Markup $: </td><td><input type=\"text\" name=\"markup\" value=\"$markup5\" class=\"TEXTB\" /></td></tr>
<tr><td>Shipping $: </td><td><input type=\"text\" name=\"shipping\" value=\"$shipping5\" class=\"TEXTB\" /></td></tr>
<tr><td>Type: </td><td><select type=\"text\" name=\"type\" class=\"SELECTA\" />
<option value=\"$type5\">$type5 &nbsp&nbsp (current)</option>"";

this fixed it

echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">

<form action=\"\" method=\"post\">
<tr><td></td><td><input type=\"hidden\" name=\"uid\" value=\"$uid\" class=\"TEXTB\" /></td></tr>
<tr><td>Item Description:</td><td><input type=\"text\" name=\"item\" value='$item5' class=\"TEXTB\" /></td></tr>
<tr><td>Ex Tax $: </td><td><input type=\"text\" name=\"cost\" value=\"$cost5\" class=\"TEXTB\" /></td></tr>
<tr><td>Markup $: </td><td><input type=\"text\" name=\"markup\" value=\"$markup5\" class=\"TEXTB\" /></td></tr>
<tr><td>Shipping $: </td><td><input type=\"text\" name=\"shipping\" value=\"$shipping5\" class=\"TEXTB\" /></td></tr>
<tr><td>Type: </td><td><select type=\"text\" name=\"type\" class=\"SELECTA\" />
<option value=\"$type5\">$type5 &nbsp&nbsp (current)</option>";

A better way would be to use the htmlentities() function.  If you used single quotes to delimit all the form attributes, it would be much cleaner code (and easier to understand):

<?php
echo "<table border='0' cellpadding='5' cellspacing='0'>
<form action='' method='post'>
<tr><td></td><td><input type='hidden' name='uid' value='$uid' class='TEXTB' /></td></tr>
<tr><td>Item Description:</td><td><input type='text' name='item' value='" . htmlentities($item5,ENT_QUOTES) . "' class='TEXTB' /></td></tr>
<tr><td>Ex Tax $: </td><td><input type='text' name='cost' value='$cost5' class='TEXTB' /></td></tr>
<tr><td>Markup $: </td><td><input type='text' name='markup' value='$markup5' class='TEXTB' /></td></tr>
<tr><td>Shipping $: </td><td><input type='text' name='shipping' value='$shipping5' class='TEXTB' /></td></tr>
<tr><td>Type: </td><td><select type='text' name='type' class='SELECTA' />
<option value='$type5'>$type5 &nbsp&nbsp (current)</option>";
?>

 

Ken

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.