Jump to content

Help me please


UnknownZ

Recommended Posts

post-142455-0-24312700-1362665604_thumb.png <<<<----- screenshot here!

<?php 
// This file is www.developphp.com curriculum material
// Written by Adam Khoury January 01, 2011
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php 
// Check to see the URL variable is set and that it exists in the database
if (isset($_GET[id'])) {
// Connect to the MySQL database
    include "storescripts/connect_to_mysql.php"; 
$id = preg_replace([^0-9]', '', $_GET["id"]); <<<<THIS IS THE PROBLEM I CANNOT FIX IT
// Use this var to check to see if this ID exists, if yes then get the product 
// details, if no then exit this script and give message why
$sql = mysql_query(SELECT * FROM products WHERE id='$id' LIMIT 1);
$productCount = mysql_num_rows($sql); // count the output amount
    if ($productCount > 0) {
// get all the product details
while($row = mysql_fetch_array($sql)){ 
$product_name = $row["product_name"];
$price = $row["price"];
$details = $row["details"];
$category = $row["category"];
$subcategory = $row["subcategory"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
         }
 
} else {
echo "That item does not exist.";
   exit();
}
 
} else {
echo "Data to render this page is missing.";
exit();
}
mysql_close();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $product_name; ?></title>
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
</head>
<body>
<div align="center" id="mainWrapper">
  <?php include_once("template_header.php");?>
  <div id="pageContent">
  <table width="100%" border="0" cellspacing="0" cellpadding="15">
  <tr>
    <td width="19%" valign="top"><img src="inventory_images/<?php echo $id; ?>.jpg" width="142" height="188" alt="<?php echo $product_name; ?>" /><br />
      <a href="inventory_images/<?php echo $id; ?>.jpg">View Full Size Image</a></td>
    <td width="81%" valign="top"><h3><?php echo $product_name; ?></h3>
      <p><?php echo "$".$price; ?><br />
        <br />
        <?php echo "$subcategory $category"; ?> <br />
<br />
        <?php echo $details; ?>
<br />
        </p>
      <form id="form1" name="form1" method="post" action="cart.php">
        <input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" />
        <input type="submit" name="button" id="button" value="Add to Shopping Cart" />
      </form>
      </td>
    </tr>
</table>
  </div>
  <?php include_once("template_footer.php");?>
</div>
</body>
</html>
Link to comment
https://forums.phpfreaks.com/topic/275369-help-me-please/
Share on other sites

Use [ code ] tags (and see)

 

// Connect to the MySQL database
    include "storescripts/connect_to_mysql.php"; 
$id = preg_replace([^0-9]', '', $_GET["id"]); #<<<<THIS IS THE PROBLEM I CANNOT FIX IT
##MAD## Missing    ^ single-quote
// Use this var to check to see if this ID exists, if yes then get the product 

 

Get an editor that highlights your code.

Link to comment
https://forums.phpfreaks.com/topic/275369-help-me-please/#findComment-1417247
Share on other sites

Use [ code ] tags (and see)

 

// Connect to the MySQL database
    include "storescripts/connect_to_mysql.php"; 
$id = preg_replace([^0-9]', '', $_GET["id"]); #<<<<THIS IS THE PROBLEM I CANNOT FIX IT
##MAD## Missing    ^ single-quote
// Use this var to check to see if this ID exists, if yes then get the product 

Get an editor that highlights your code.

 how about this 

 

Fatal error: Call to undefined function money_format() in D:\xampp\htdocs\Anonymous1\cart.php on line 120
 
while ($row = mysql_fetch_array($sql)) {
$product_name = $row["product_name"];
$price = $row["price"];
$details = $row["details"];
}
$pricetotal = $price * $each_item['quantity'];
$cartTotal = $pricetotal + $cartTotal;
setlocale(LC_MONETARY, "en_US");
        $pricetotal = money_format("%10.2n", $pricetotal); <<<< ERROR AGAIN
// Dynamic Checkout Btn Assembly
$x = $i + 1;
$pp_checkout_btn .= '<input type="hidden" name="item_name_' . $x . '" value="' . $product_name . '">
        <input type="hidden" name="amount_' . $x . '" value="' . $price . '">
        <input type="hidden" name="quantity_' . $x . '" value="' . $each_item['quantity'] . '">  ';
// Create the product array variable
$product_id_array .= "$item_id-".$each_item['quantity'].","; 
// Dynamic table row assembly
$cartOutput .= "<tr>";
$cartOutput .= '<td><a href="product.php?id=' . $item_id . '">' . $product_name . '</a><br /><img src="inventory_images/' . $item_id . '.jpg" alt="' . $product_name. '" width="40" height="52" border="1" /></td>';
Link to comment
https://forums.phpfreaks.com/topic/275369-help-me-please/#findComment-1417426
Share on other sites

Please use [ code ] tags when providing code on the forum. It formats it nicely so it is easy to read (and often points out problems with syntax).
while ($row = mysql_fetch_array($sql)) {
$product_name = $row["product_name"];
$price = $row["price"];
$details = $row["details"];
}
$pricetotal = $price * $each_item['quantity'];
$cartTotal = $pricetotal + $cartTotal;
setlocale(LC_MONETARY, "en_US");
$pricetotal = money_format(".2n", $pricetotal); <<<< ERROR AGAIN
// Dynamic Checkout Btn Assembly
$x = $i + 1;
$pp_checkout_btn .= '<input type="hidden" name="item_name_' . $x . '" value="' . $product_name . '">
<input type="hidden" name="amount_' . $x . '" value="' . $price . '">
<input type="hidden" name="quantity_' . $x . '" value="' . $each_item['quantity'] . '"> ';
// Create the product array variable
$product_id_array .= "$item_id-".$each_item['quantity'].",";
// Dynamic table row assembly
$cartOutput .= "<tr>";
$cartOutput .= '<td><a href="product.php?id=' . $item_id . '">' . $product_name . '</a><br /><img src="inventory_images/' . $item_id . '.jpg" alt="' . $product_name. '" width="40" height="52" border="1" /></td>';
money_format should be available in any PHP from 4.3 up. Don't tell me you are using something less than 4.3? I mean, 5.3 is almost considered OLD.
Link to comment
https://forums.phpfreaks.com/topic/275369-help-me-please/#findComment-1417430
Share on other sites

 

Please use [ code ] tags when providing code on the forum. It formats it nicely so it is easy to read (and often points out problems with syntax).

while ($row = mysql_fetch_array($sql)) {
$product_name = $row["product_name"];
$price = $row["price"];
$details = $row["details"];
}
$pricetotal = $price * $each_item['quantity'];
$cartTotal = $pricetotal + $cartTotal;
setlocale(LC_MONETARY, "en_US");
        $pricetotal = money_format(".2n", $pricetotal); <<<< ERROR AGAIN
// Dynamic Checkout Btn Assembly
$x = $i + 1;
$pp_checkout_btn .= '<input type="hidden" name="item_name_' . $x . '" value="' . $product_name . '">
        <input type="hidden" name="amount_' . $x . '" value="' . $price . '">
        <input type="hidden" name="quantity_' . $x . '" value="' . $each_item['quantity'] . '">  ';
// Create the product array variable
$product_id_array .= "$item_id-".$each_item['quantity'].","; 
// Dynamic table row assembly
$cartOutput .= "<tr>";
$cartOutput .= '<td><a href="product.php?id=' . $item_id . '">' . $product_name . '</a><br /><img src="inventory_images/' . $item_id . '.jpg" alt="' . $product_name. '" width="40" height="52" border="1" /></td>';
money_format should be available in any PHP from 4.3 up. Don't tell me you are using something less than 4.3? I mean, 5.3 is almost considered OLD.

stil error im using xampp. im not very good at php

Link to comment
https://forums.phpfreaks.com/topic/275369-help-me-please/#findComment-1417432
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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