instead of using break use exit() where u have ur breaks and will work fine
> -----Original Message----- > From: Marek Kilimajer [mailto:kilimajer@;webglobe.sk] > Sent: Tuesday, 29 October 2002 1:30 AM > To: PHP > Subject: Re: [PHP] New Error? > > > Break an continue are for loops (while,for ...), if you want to get out > of a function, use return > > Steve Jackson wrote: > > >I get this error from my code. > >Fatal error: Cannot break/continue 1 levels in > >/www/u1255/shop/purchase.php on line 22 > > > >I think I need to end the functions if a condition is met so is there a > >way to do it without breaking? > >Where do I go from here? > > > ><? > > > > include ('products_sc_fns.php'); > > // The shopping cart needs sessions, so start one > > session_start(); > > > > do_html_header("Checkout"); > > // if filled out > > //echo "testing"; > > if($cart&&$name&&$address&&$city&&$zip&&$country) > > > > { > > // able to insert into database > > if( insert_order($HTTP_POST_VARS)!=false ) > > { > > //display cart, not allowing changes and without pictures > > display_cart($cart, false, 0); > > calculate_weight($cart); > > //determine what shipping we are using > > if ($country!="Finland"){ > > display_shipping(calculate_nonfinland_cost($country)); > > break; > > } > > elseif ($country=="Finland" && $express=="no"){ > > display_shipping(calculate_shipping_cost($weight)); > > break; > > } > > elseif ($country=="Finland" && $express=="yes"){ > > display_shipping(calculate_express_cost($express)); > > break; > > } > > > > //de-bug > > echo "test & $country & $express"; > > //if($country!="Finland") > > //display_shipping(calculate_shipping_cost($weight)); > > //{ > > //display_shipping(calculate_nonfinland_cost($country)); > > //} > > //display_shipping(calculate_express_cost($express)); > > //display_shipping(calculate_temp_shipping_cost($weight)); > > //get credit card details > > calculate_final_cost($total_price, $shipping); > > get_order_id(); > > display_card_form($name, $final_cost); > > echo "<table width='760' cellpadding='0' > >background='images/shopbg.gif'><tr><td width='200'> </td>"; > > echo "<td align='right'>"; > > display_button("show_cart.php", "continue-shopping", "Continue > >Shopping"); > > echo "</td></tr></table>"; > > } > > else > > { > > echo mysql_error(); > > echo "<table width='760' cellpadding='0' > >background='images/shopbg.gif'><tr><td width='200'> </td><td>Could > >not store data, please try again.</td>"; > > echo "<tr><td width='200'> </td><td>"; > > display_button("checkout.php", "back", "Back"); > > echo "</td></tr></table>"; > > } > > } > > else > > { > > echo "<table width='760' cellpadding='0' > >background='images/shopbg.gif'><tr><td width='200'> </td><td>You > >did not fill in all the fields, please try again.</td>"; > > echo "<tr><td width='200'> </td><td>"; > > display_button("checkout.php", "back", "Back"); > > echo "</td></tr></table>"; > > } > > > > do_html_footer(); > >?> > > > > > > > >Steve Jackson > >Web Developer > >Viola Systems Ltd. > >http://www.violasystems.com <http://www.violasystems.com/> > >[EMAIL PROTECTED] > >Mobile +358 50 343 5159 > > > > > > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php