deleting an order using php and sql ?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ashebrian
Forum Contributor
Posts: 103
Joined: Sat Feb 02, 2008 8:01 pm

deleting an order using php and sql ?

Post by ashebrian »

Hi,

I have the following codes to delete an order i already have in my sql db. When i click on delete my order i get a javascript alert box that does exactly as i asked it to do. However, afer i click ok in the alert box to delete the order, the order i deleted is still there displayed. Can you please help as i'm clueless about this? Here's the codes:

processOrder.php

Code: Select all

<?php
require_once '../../library/config.php';
require_once '../library/functions.php';
 
checkUser();
 
$action = isset($_GET['action']) ? $_GET['action'] : '';
 
switch ($action) {
        
    case 'deleteOrder' :
        deleteOrder();
        break;
 
    default :
        // if action is not defined or unknown
        // move to main order page
        header('Location: index.php');
}
/*
    Remove an order
*/
function deleteOrder()
{
    if (isset($_GET['oid']) && (int)$_GET['oid'] > 0){
        $orderId = (int)$_GET['oid'];
    } else {
        header('Location: index.php');
    }
    
    // remove any references to this order from
    // tbl_order_item and tbl_order
    $sql = "DELETE FROM tbl_order_item
            WHERE od_id = $orderId";
    dbQuery($sql);
            
    $result = dbQuery($sql);
    $row    = dbFetchAssoc($result);
    
    // remove the order from database;
    $sql = "DELETE FROM tbl_order 
            WHERE od_id = $orderId";
    dbQuery($sql);
    
    header('Location: index.php');
}
 
?>
 
inside list.php

Code: Select all

<td width="70" align="center"><a href="javascript&#058;deleteOrder(<?php echo $od_id; ?>);">Delete</a></td>
inside my sql table tbl_order

Code: Select all

CREATE TABLE `tbl_order` (
`od_id` int(10) unsigned NOT NULL auto_increment,
.
.
.
PRIMARY KEY  (`od_id`)
 
inside my sql table tbl_order_item

Code: Select all

CREATE TABLE `tbl_order_item` (
`od_id` int(10) unsigned NOT NULL default '0',
.
.
.
PRIMARY KEY  (`od_id`,`pd_id`)
 
You'd be of great help if you can sort this problem
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: deleting an order using php and sql ?

Post by John Cartwright »

Code: Select all

   // remove any references to this order from
    // tbl_order_item and tbl_order
    $sql = "DELETE FROM tbl_order_item
            WHERE od_id = $orderId";
    dbQuery($sql);
           
    $result = dbQuery($sql);
    $row    = dbFetchAssoc($result);
   
    // remove the order from database;
    $sql = "DELETE FROM tbl_order
            WHERE od_id = $orderId";
    dbQuery($sql);
Take a look carefully here.

1) You are performing the delete 3 times
2) You are trying to fetch an associative array from the delete query, which is not valid
3) Try echo'ing $sql to see what is being queried.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: deleting an order using php and sql ?

Post by Christopher »

And check if errors are occurring.
(#10850)
ashebrian
Forum Contributor
Posts: 103
Joined: Sat Feb 02, 2008 8:01 pm

Re: deleting an order using php and sql ?

Post by ashebrian »

ere's what i did:

Code: Select all

{
    if (isset($_GET['oid']) && (int)$_GET['oid'] > 0){
        $orderId = (int)$_GET['oid'];
    } else {
        header('Location: index.php');
    }
    
    // remove any references to this order from
    // tbl_order_item
    $sql = "DELETE FROM tbl_order_item
            WHERE od_id = $orderId";
    dbQuery($sql);
            
    $result = dbQuery($sql);
    
    // remove the order from database;
    $sql = "DELETE FROM tbl_order 
            WHERE od_id = $orderId";
    echo dbQuery($sql);
    
    header('Location: index.php');
}
Same reply. and:

Code: Select all

    $sql = "DELETE FROM tbl_order_item, tbl_order
            WHERE od_id = $orderId";
    dbQuery($sql);
            
    $result = dbQuery($sql);
    
    header('Location: index.php');
}
 
?>
both codes give me the same reply.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: deleting an order using php and sql ?

Post by John Cartwright »

I suggest you re-read my post, very carefully.

I also suggest you count the amount of times your calling db_query() in your delete routine.
ashebrian
Forum Contributor
Posts: 103
Joined: Sat Feb 02, 2008 8:01 pm

Re: deleting an order using php and sql ?

Post by ashebrian »

i've tried a number of solutions. Allowed myself to call the db_query once, i've changed my code 5 - 7 times and got to

Code: Select all

function deleteOrder()
{
    if (isset($_GET['oid']) && (int)$_GET['oid'] > 0){
        $orderId = (int)$_GET['oid'];
    } else {
        header('Location: index.php');
    }
    
    // remove any references to this order from
    // tbl_order_item
    $sql = "DELETE FROM tbl_order_item, tbl_order
            WHERE od_id = $orderId";        
    echo ($sql);
    
    header('Location: index.php');
}
 
?>
I've done sql years ago and have to relearn it all again. It sounds like i've wasted those years. Any chance you can give me ur solution as i'm a newbie to php.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: deleting an order using php and sql ?

Post by John Cartwright »

ashebrian wrote:i've tried a number of solutions. Allowed myself to call the db_query once, i've changed my code 5 - 7 times and got to

Code: Select all

function deleteOrder()
{
    //.. 
    echo 'OrderID: '. $orderId .'<br>';
 
    $sql = "DELETE FROM tbl_order_item, tbl_order
            WHERE od_id = $orderId";        
    mysql_query($sql) or die(mysql_errror());
    echo $sql .'<br>';
    echo 'Affected rows: '. mysql_affected_rows();
 
    $sql = "DELETE FROM tbl_order
            WHERE od_id = $orderId";
    mysql_query($sql) or die(mysql_errror());
    echo '<br>'. $sql .'<br>';
    echo 'Affected rows: '. mysql_affected_rows();
    //..
}
 
?>
And what does this script output?
ashebrian wrote:Any chance you can give me ur solution as i'm a newbie to php.
I don't know whats causing your problem.. which is why I've asked you to display the output of $sql :evil: Regardless, I'm not here to do your work for you, and considering this is a place of learning I think that is counter-intuitive to do the work for you (especially when you are so close).
ashebrian
Forum Contributor
Posts: 103
Joined: Sat Feb 02, 2008 8:01 pm

Re: deleting an order using php and sql ?

Post by ashebrian »

I know ur not ere to do the work. I'm only asking for the solutions as this is the reason i'm post them online as i'm stuck. You want to know what happens in the sql db when delete button is clicked and whats displayed:

my tables is as follows:

Code: Select all

CREATE TABLE `tbl_order_item` (
  `od_id` int(10) unsigned NOT NULL default '0',
  `pd_id` int(10) unsigned NOT NULL default '0',
  `od_qty` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`od_id`,`pd_id`)
) TYPE=MyISAM;

and:

Code: Select all

CREATE TABLE `tbl_order` (
  `od_id` int(10) unsigned NOT NULL auto_increment,
  `od_date` datetime default NULL,
  `od_last_update` datetime NOT NULL default '0000-00-00 00:00:00',
  `od_status` enum('New', 'Paid', 'Shipped','Completed','Cancelled') NOT NULL default 'New',
  `od_memo` varchar(255) NOT NULL default '',
  `od_shipping_first_name` varchar(50) NOT NULL default '',
  `od_shipping_last_name` varchar(50) NOT NULL default '',
  `od_shipping_address1` varchar(100) NOT NULL default '',
  `od_shipping_address2` varchar(100) NOT NULL default '',
  `od_shipping_phone` varchar(32) NOT NULL default '',
  `od_shipping_city` varchar(100) NOT NULL default '',
  `od_shipping_state` varchar(32) NOT NULL default '',
  `od_shipping_postal_code` varchar(10) NOT NULL default '',
  `od_shipping_cost` decimal(5,2) default '0.00',
  `od_payment_first_name` varchar(50) NOT NULL default '',
  `od_payment_last_name` varchar(50) NOT NULL default '',
  `od_payment_address1` varchar(100) NOT NULL default '',
  `od_payment_address2` varchar(100) NOT NULL default '',
  `od_payment_phone` varchar(32) NOT NULL default '',
  `od_payment_city` varchar(100) NOT NULL default '',
  `od_payment_state` varchar(32) NOT NULL default '',
  `od_payment_postal_code` varchar(10) NOT NULL default '',
  PRIMARY KEY  (`od_id`)
) TYPE=MyISAM AUTO_INCREMENT=1001 ;
.... from all the changes i've been doing, little errors came up but i fixed them. What comes up for so long in the output is that it looks like the page is just being refreshed and the order is not deleted. However, the same thing happened to your code that i put in. The sql db has not be changed while the order details are still in there.

ere's the processOrder.php

Code: Select all

<?php
require_once '../../library/config.php';
require_once '../library/functions.php';
 
checkUser();
 
$action = isset($_GET['action']) ? $_GET['action'] : '';
 
switch ($action) {
    case 'modify' :
        modifyOrder();
        break;
        
    case 'deleteOrder' :
        deleteOrder();
        break;
 
    default :
        // if action is not defined or unknown
        // move to main order page
        header('Location: index.php');
}
 
 
 
function modifyOrder()
{
    if (!isset($_GET['oid']) || (int)$_GET['oid'] <= 0
        || !isset($_GET['status']) || $_GET['status'] == '') {
        header('Location: index.php');
    }
    
    $orderId = (int)$_GET['oid'];
    $status  = $_GET['status'];
    
    $sql = "UPDATE tbl_order
            SET od_status = '$status', od_last_update = NOW()
            WHERE od_id = $orderId";
    $result = dbQuery($sql);
    
    header("Location: index.php?view=list&status=$status");    
}
 
/*
    Remove an order
*/
function deleteOrder()
{
    if (isset($_GET['oid']) && (int)$_GET['oid'] > 0){
        $orderId = (int)$_GET['oid'];
    } else {
        header('Location: index.php');
    }
    
    // remove any references to this order from
    // tbl_order_item
     $sql = "DELETE FROM tbl_order_item, tbl_order
            WHERE od_id = $orderId";        
     mysql_query($sql);
     echo $sql .'<br>';
     echo 'Affected rows: '. mysql_affected_rows();
    
    header('Location: index.php');
}
 
?>
list.php

Code: Select all

<?php
if (!defined('WEB_ROOT')) {
    exit;
}
 
 
if (isset($_GET['status']) && $_GET['status'] != '') {
    $status = $_GET['status'];
    $sql2   = " AND od_status = '$status'";
    $queryString = "&status=$status";
} else {
    $status = '';
    $sql2   = '';
    $queryString = '';
}   
 
// for paging
// how many rows to show per page
$rowsPerPage = 10;
 
$sql = "SELECT o.od_id, o.od_shipping_first_name, od_shipping_last_name, od_date, od_status,
               SUM(pd_price * od_qty) + od_shipping_cost AS od_amount
        FROM tbl_order o, tbl_order_item oi, tbl_product p 
        WHERE oi.pd_id = p.pd_id and o.od_id = oi.od_id $sql2
        GROUP BY od_id
        ORDER BY od_id DESC";
$result     = dbQuery(getPagingQuery($sql, $rowsPerPage));
$pagingLink = getPagingLink($sql, $rowsPerPage, $queryString);
 
$orderStatus = array('New', 'Paid', 'Shipped', 'Completed', 'Cancelled');
$orderOption = '';
foreach ($orderStatus as $stat) {
    $orderOption .= "<option value=\"$stat\"";
    if ($stat == $status) {
        $orderOption .= " selected";
    }
    
    $orderOption .= ">$stat</option>\r\n";
}
?> 
<p>&nbsp;</p>
<form action="processOrder.php" method="post"  name="frmOrderList" id="frmOrderList">
 <table width="100%" border="0" cellspacing="0" cellpadding="2" class="text">
 <tr align="center"> 
  <td align="right" style="color:#cc0033">View</td>
  <td width="75"><select name="cboOrderStatus" class="box" id="cboOrderStatus" onChange="viewOrder();">
    <option value="" selected>All</option>
    <?php echo $orderOption; ?>
  </select></td>
  </tr>
</table>
 
 <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="text">
  <tr align="center" id="listTableHeader"> 
   <td width="60">Order #</td>
   <td>Customer Name</td>
   <td width="60">Amount</td>
   <td width="150">Order Time</td>
   <td width="70">Status</td>
   <td width="70">Delete</td>
  </tr>
  <?php
$parentId = 0;
if (dbNumRows($result) > 0) {
    $i = 0;
    
    while($row = dbFetchAssoc($result)) {
        extract($row);
        $name = $od_shipping_first_name . ' ' . $od_shipping_last_name;
        
        if ($i%2) {
            $class = 'row1';
        } else {
            $class = 'row2';
        }
        
        $i += 1;
?>
  <tr class="<?php echo $class; ?>"> 
   <td width="60"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?view=detail&oid=<?php echo $od_id; ?>"><?php echo $od_id; ?></a></td>
   <td><?php echo $name ?></td>
   <td width="60" align="right"><?php echo displayAmount($od_amount); ?></td>
   <td width="150" align="center"><?php echo $od_date; ?></td>
   <td width="70" align="center"><?php echo $od_status; ?></td>
   <td width="70" align="center"><a href="javascript&#058;deleteOrder(<?php echo $od_id; ?>);">Delete</a></td>
  </tr>
  <?php
    } // end while
 
?>
  <tr> 
   <td colspan="6" align="center">
   <?php 
   echo $pagingLink;
   ?></td>
  </tr>
<?php
} else {
?>
  <tr> 
   <td colspan="6" align="center">No Orders Found </td>
  </tr>
  <?php
}
?>
 
 </table>
 <p>&nbsp;</p>
</form>
details.php

Code: Select all

<?php
if (!defined('WEB_ROOT')) {
    exit;
}
 
if (!isset($_GET['oid']) || (int)$_GET['oid'] <= 0) {
    header('Location: index.php');
}
 
$orderId = (int)$_GET['oid'];
 
// get ordered items
$sql = "SELECT pd_name, pd_price, od_qty
        FROM tbl_order_item oi, tbl_product p 
        WHERE oi.pd_id = p.pd_id and oi.od_id = $orderId
        ORDER BY od_id ASC";
 
$result = dbQuery($sql);
$orderedItem = array();
while ($row = dbFetchAssoc($result)) {
    $orderedItem[] = $row;
}
 
 
// get order information
$sql = "SELECT od_date, od_last_update, od_status, od_shipping_first_name, od_shipping_last_name, od_shipping_address1, 
               od_shipping_address2, od_shipping_phone, od_shipping_state, od_shipping_city, od_shipping_postal_code, od_shipping_cost, 
               od_payment_first_name, od_payment_last_name, od_payment_address1, od_payment_address2, od_payment_phone,
               od_payment_state, od_payment_city , od_payment_postal_code,
               od_memo
        FROM tbl_order 
        WHERE od_id = $orderId";
 
$result = dbQuery($sql);
extract(dbFetchAssoc($result));
 
$orderStatus = array('New', 'Paid', 'Shipped', 'Completed', 'Cancelled');
$orderOption = '';
foreach ($orderStatus as $status) {
    $orderOption .= "<option value=\"$status\"";
    if ($status == $od_status) {
        $orderOption .= " selected";
    }
    
    $orderOption .= ">$status</option>\r\n";
}
?>
<p>&nbsp;</p>
<form action="" method="get" name="frmOrder" id="frmOrder">
    <table width="550" border="0"  align="center" cellpadding="5" cellspacing="1" class="detailTable">
        <tr> 
            <td colspan="2" align="center" id="infoTableHeader">Order Detail</td>
        </tr>
        <tr> 
            <td width="150" class="label">Order Number</td>
            <td class="content"><?php echo $orderId; ?></td>
        </tr>
        <tr> 
            <td width="150" class="label">Order Date</td>
            <td class="content"><?php echo $od_date; ?></td>
        </tr>
        <tr> 
            <td width="150" class="label">Last Update</td>
            <td class="content"><?php echo $od_last_update; ?></td>
        </tr>
        <tr> 
            <td class="label">Status</td>
            <td class="content"> <select name="cboOrderStatus" id="cboOrderStatus" class="box">
                    <?php echo $orderOption; ?> </select> <input name="btnModify" type="button" id="btnModify" value="Modify Status" class="boxbutton" onClick="modifyOrderStatus(<?php echo $orderId; ?>);"></td>
        </tr>
    </table>
</form>
<p>&nbsp;</p>
<table width="550" border="0"  align="center" cellpadding="5" cellspacing="1" class="detailTable">
    <tr id="infoTableHeader"> 
        <td colspan="3">Ordered Item</td>
    </tr>
    <tr align="center" class="label"> 
        <td>Item</td>
        <td>Unit Price</td>
        <td>Total</td>
    </tr>
    <?php
$numItem  = count($orderedItem);
$subTotal = 0;
for ($i = 0; $i < $numItem; $i++) {
    extract($orderedItem[$i]);
    $subTotal += $pd_price * $od_qty;
?>
    <tr class="content"> 
        <td><?php echo "$od_qty X $pd_name"; ?></td>
        <td align="right"><?php echo displayAmount($pd_price); ?></td>
        <td align="right"><?php echo displayAmount($od_qty * $pd_price); ?></td>
    </tr>
    <?php
}
?>
    <tr class="content"> 
        <td colspan="2" align="right">Sub-total</td>
        <td align="right"><?php echo displayAmount($subTotal); ?></td>
    </tr>
    <tr class="content"> 
        <td colspan="2" align="right">Shipping</td>
        <td align="right"><?php echo displayAmount($od_shipping_cost); ?></td>
    </tr>
    <tr class="content"> 
        <td colspan="2" align="right">Total</td>
        <td align="right"><?php echo displayAmount($od_shipping_cost + $subTotal); ?></td>
    </tr>
</table>
<p>&nbsp;</p>
<table width="550" border="0"  align="center" cellpadding="5" cellspacing="1" class="detailTable">
    <tr id="infoTableHeader"> 
        <td colspan="2">Shipping Information</td>
    </tr>
    <tr> 
        <td width="150" class="label">First Name</td>
        <td class="content"><?php echo $od_shipping_first_name; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Last Name</td>
        <td class="content"><?php echo $od_shipping_last_name; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Address1</td>
        <td class="content"><?php echo $od_shipping_address1; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Address2</td>
        <td class="content"><?php echo $od_shipping_address2; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Phone Number</td>
        <td class="content"><?php echo $od_shipping_phone; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Province / State</td>
        <td class="content"><?php echo $od_shipping_state; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">City</td>
        <td class="content"><?php echo $od_shipping_city; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Postal Code</td>
        <td class="content"><?php echo $od_shipping_postal_code; ?> </td>
    </tr>
</table>
<p>&nbsp;</p>
<table width="550" border="0"  align="center" cellpadding="5" cellspacing="1" class="detailTable">
    <tr id="infoTableHeader"> 
        <td colspan="2">Payment Information</td>
    </tr>
    <tr> 
        <td width="150" class="label">First Name</td>
        <td class="content"><?php echo $od_payment_first_name; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Last Name</td>
        <td class="content"><?php echo $od_payment_last_name; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Address1</td>
        <td class="content"><?php echo $od_payment_address1; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Address2</td>
        <td class="content"><?php echo $od_payment_address2; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Phone Number</td>
        <td class="content"><?php echo $od_payment_phone; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Province / State</td>
        <td class="content"><?php echo $od_payment_state; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">City</td>
        <td class="content"><?php echo $od_payment_city; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Postal Code</td>
        <td class="content"><?php echo $od_payment_postal_code; ?> </td>
    </tr>
</table>
<p>&nbsp;</p>
<table width="550" border="0"  align="center" cellpadding="5" cellspacing="1" class="detailTable">
    <tr id="infoTableHeader"> 
        <td colspan="2">Buyer's Memo</td>
    </tr>
    <tr> 
        <td colspan="2" class="label"><?php echo nl2br($od_memo); ?> </td>
    </tr>
</table>
<p>&nbsp;</p>
<p align="center"> 
    <input name="btnBack" type="button" id="btnBack" value="Back" class="boxbutton" onClick="window.history.back();">
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
 
and index.php

Code: Select all

<?php
require_once '../../library/config.php';
require_once '../library/functions.php';
 
$_SESSION['login_return_url'] = $_SERVER['REQUEST_URI'];
checkUser();
 
$view = (isset($_GET['view']) && $_GET['view'] != '') ? $_GET['view'] : '';
 
switch ($view) {
    case 'list' :
        $content    = 'list.php';       
        $pageTitle  = '&Eacute;al&uacute; MediSpa Thearpy Control Panel - View Orders';
        break;
 
    case 'detail' :
        $content    = 'detail.php';     
        $pageTitle  = '&Eacute;al&uacute; MediSpa Thearpy Control Panel - Order Detail';
        break;
 
    case 'modify' :
        modifyStatus();
        //$content  = 'modify.php';     
        //$pageTitle    = '&Eacute;al&uacute; MediSpa Thearpy Control Panel - Modify Orders';
        break;
 
    default :
        $content    = 'list.php';       
        $pageTitle  = '&Eacute;al&uacute; MediSpa Thearpy Control Panel - View Orders';
}
 
 
 
 
$script    = array('order.js');
 
require_once '../include/template.php';
?>
 
Will this info help?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: deleting an order using php and sql ?

Post by John Cartwright »

What helps is providing the information I'm asking for..

until then..
ashebrian
Forum Contributor
Posts: 103
Joined: Sat Feb 02, 2008 8:01 pm

Re: deleting an order using php and sql ?

Post by ashebrian »

here's the output:
Warning: Missing argument 1 for deleteorder() in C:\Inetpub\vhosts\eeee.com\order\processOrder.php on line 48

Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\vhosts\eeeee.com\order\processOrder.php:48) in C:\Inetpub\vhosts\eeeee.com\order\processOrder.php on line 60
line 48 is :

Code: Select all

/*
    Remove an order
*/
function deleteOrder($orderId)
{ [color=#FF0000]<---here is line 48[/color]
    if (!$orderId && isset($_GET['oid']) && (int)$_GET['oid'] > 0){
        $orderId = (int)$_GET['oid'];
    }
    if ($orderId) { 
        $sql = "DELETE FROM tbl_order, tbl_order_item
                WHERE od_id = $orderId";
 
        $result = dbQuery($sql);
    }
 
    header('Location: index.php');
}[color=#FF0000]<---here is line 60[/color]
 
?> 
 
do i need to give the folder permission on the server??

I'm clueless as it says missing char.....i dunno where de error is.
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: deleting an order using php and sql ?

Post by flying_circus »

ashebrian wrote:here's the output:
Warning: Missing argument 1 for deleteorder() in C:\Inetpub\vhosts\eeee.com\order\processOrder.php on line 48

Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\vhosts\eeeee.com\order\processOrder.php:48) in C:\Inetpub\vhosts\eeeee.com\order\processOrder.php on line 60
line 48 is :

Code: Select all

/*
    Remove an order
*/
function deleteOrder([color=#00FF40]{[/color]$orderId[color=#00FF40]} <---- Argument 1[/color])
{ [color=#FF0000]<---here is line 48[/color]
    if (!$orderId && isset($_GET['oid']) && (int)$_GET['oid'] > 0){
        $orderId = (int)$_GET['oid'];
    }
    if ($orderId) { 
        $sql = "DELETE FROM tbl_order, tbl_order_item
                WHERE od_id = $orderId";
 
        $result = dbQuery($sql);
    }
 
    header('Location: index.php');
}[color=#FF0000]<---here is line 60[/color]
 
?> 
 
do i need to give the folder permission on the server??

I'm clueless as it says missing char.....i dunno where de error is.
ashebrian
Forum Contributor
Posts: 103
Joined: Sat Feb 02, 2008 8:01 pm

Re: deleting an order using php and sql ?

Post by ashebrian »

i got a parsing error after inputting ur code:
Parse error: parse error, expecting `')'' in C:\Inetpub\vhosts\eeee.com\order\processOrder.php on line 47

Code: Select all

/*
    Remove an order
*/
function deleteOrder({$orderId} <---- Argument 1)[color=#BF0000]<---here is line 47[/color]
{
    if (!$orderId && isset($_GET['oid']) && (int)$_GET['oid'] > 0){
        $orderId = (int)$_GET['oid'];
    }
    if ($orderId) { 
        $sql = "DELETE FROM tbl_order, tbl_order_item
                WHERE od_id = $orderId";
 
        $result = dbQuery($sql);
    }
 
    header('Location: index.php');
}
Post Reply