/    Sign up×
Community /Pin to ProfileBookmark

money_format not working

I have done my research and people said to use number_format instead but it doesn’t like that either any ideas are much appreciated and thanks in advance.

I get the following errors

Error on line 118 I fix that then any where else it says money_format and change it to number_format and then i get errors there to so I don’t know what I’m doing wrong.

$cartOutput = “”;
$cartTotal = “”;
$pp_checkout_btn = ”;
$product_id_array = ”;
if (!isset($_SESSION[“cart_array”]) || count($_SESSION[“cart_array”]) < 1) {
$cartOutput = “<h2 align=’center’>Your shopping cart is empty</h2>”;
} else {
// Start PayPal Checkout Button
$pp_checkout_btn .= ‘<form action=”https://www.paypal.com/cgi-bin/webscr” method=”post”>
<input type=”hidden” name=”cmd” value=”_cart”>
<input type=”hidden” name=”upload” value=”1″>
<input type=”hidden” name=”business” value=”[email protected]“>’;
// Start the For Each loop
$i = 0;
foreach ($_
SESSION[“cart_array”] as $each_item) {
$item_id = $each_item[‘item_id’];
$sql = mysql_query(“SELECT * FROM products WHERE id=’$item_id’ LIMIT 1″);
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);
// 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>’;
$cartOutput .= ‘<td>’ . $details . ‘</td>’;
$cartOutput .= ‘<td>$’ . $price . ‘</td>’;
$cartOutput .= ‘<td><form action=”cart.php” method=”post”>
<input name=”quantity” type=”text” value=”‘ . $each_item[‘quantity’] . ‘” size=”1″ maxlength=”2″ />
<input name=”adjustBtn’ . $item_id . ‘” type=”submit” value=”change” />
<input name=”item_to_adjust” type=”hidden” value=”‘ . $item_id . ‘” />
</form></td>’;
//$cartOutput .= ‘<td>’ . $each_item[‘quantity’] . ‘</td>’;
$cartOutput .= ‘<td>’ . $pricetotal . ‘</td>’;
$cartOutput .= ‘<td><form action=”cart.php” method=”post”><input name=”deleteBtn’ . $item_id . ‘” type=”submit” value=”X” /><input name=”index_to_remove” type=”hidden” value=”‘ . $i . ‘” /></form></td>’;
$cartOutput .= ‘</tr>’;
$i++;
}
setlocale(LC_MONETARY, “en_US”);
$cartTotal = money_format(“%10.2n”, $cartTotal);
$cartTotal = “<div style=’font-size:18px; margin-top:12px;’ align=’right’>Cart Total : “.$cartTotal.” USD</div>”;
// Finish the Paypal Checkout Btn
$pp_checkout_btn .= ‘<input type=”hidden” name=”custom” value=”‘ . $product_id_array . ‘”>
<input type=”hidden” name=”notify_url” value=”https://www.yoursite.com/storescripts/my_ipn.php“>
<input type=”hidden” name=”return” value=”https://www.yoursite.com/checkout_complete.php“>
<input type=”hidden” name=”rm” value=”2″>
<input type=”hidden” name=”cbt” value=”Return to The Store”>
<input type=”hidden” name=”cancel_return” value=”https://www.yoursite.com/paypal_cancel.php“>
<input type=”hidden” name=”lc” value=”US”>
<input type=”hidden” name=”currency_code” value=”USD”>
<input type=”image” src=”http://www.paypal.com/en_US/i/btn/x-click-but01.gif” name=”submit” alt=”Make payments with PayPal – its fast, free and secure!”>
</form>’;
}
?>

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 04.2011 — [url=http://php.net/money_format]money_format[/url]() and [url=http://php.net/number_format]number_format[/url]() have different parameter lists, so you cannot just change the function name without changing the parameter list sequence and values.
Copy linkTweet thisAlerts:
@shutterbugauthorMar 04.2011 — Went online and now its not a problem thank you for the help.
Copy linkTweet thisAlerts:
@AntiFaith33Apr 04.2011 — how did you fix it? I am having the same problem now
Copy linkTweet thisAlerts:
@shutterbugauthorApr 04.2011 — AntiFaith33. Actually all I did was make it live instead of testing on a local hosting server. Then it worked. Hope it works for you.
Copy linkTweet thisAlerts:
@AntiFaith33Apr 05.2011 — My problem was because I was using a windows server on goDaddy.com. money_format() isn't valid on windows, so I changed the hosting service to a Linux server and it all worked great, now just to encrypt the bloody thing for paypal...
Copy linkTweet thisAlerts:
@shutterbugauthorApr 05.2011 — Yep that works to. Windows servers just don't like it.
×

Success!

Help @shutterbug spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...