Jump to content

ughh.. im getting so annoyed!


jwk811

Recommended Posts

i have written up a page of functions and lost them now im re-writting them and im having some problems.. i get a unexpected t string error on the bolded line (and dont mind the sql functions ive simplified them and they are working fine) thanks for any help, oh and this is a product list in my admin pages that i sort with arrows and this is a function where the admin clicks the up arrow and the product re-arranges by the number of size because that how they will be listed....

 

function moveUp()
{
$pid = $_GET['Id'];

$sql = "SELECT id, size FROM products WHERE id != '$pid'";
$result = dbQuery($sql);

    if(dbNumRows($result) == 1){
$row = mysql_fetch_assoc($result);
extract($row);

$sql = "UPDATE products SET size += 1 WHERE id = '$id';
$result = dbQuery($sql);

[b]	$sql = "UPDATE products SET size -= 1 WHERE id = '$pid'";[/b]
$result = dbQuery($sql);
    }
    else{
exit();
    }

header("Location: index.php");

}

Link to comment
Share on other sites

crap! new problem.. heres entire code

unexpected $

<?php
require_once '../../library/config.php';
require_once '../library/functions.php';

checkUser();

$action = isset($_GET['action']) ? $_GET['action'] : '';
switch ($action) {

    case 'add' :
        addCategory();
        break;
      
    case 'modify' :
        modifyCategory();
        break;
        
    case 'delete' :
        deleteCategory();
        break;
    
    case 'moveUp' :
moveUp();
break;
   
    case 'moveDown' :
moveDown();
break;

    default :
        // if action is not defined or unknown
        // move to main category page
        header('Location: index.php');
}

function moveUp()
{
$pid = $_GET['Id'];

$sql = "SELECT id, size FROM products WHERE id != '$pid'";
$result = dbQuery($sql);

    if(dbNumRows($result) == 1){
$row = mysql_fetch_assoc($result);
extract($row);

$sql = "UPDATE products SET size += 1 WHERE id = '$id'";
$result = dbQuery($sql);

$sql = "UPDATE products SET size -= 1 WHERE id = '$pid'";
$result = dbQuery($sql);
    }
    else{
exit();
    }

header("Location: index.php");

}

function moveDown()
{
$pid = $_GET['Id'];

$sql = "SELECT id, size FROM products WHERE id != '$pid'";
$result = dbQuery($sql);

    if(dbNumRows($result) == 1){
$row = mysql_fetch_assoc($result);
extract($row);

$sql = "UPDATE products SET size = size + 1 WHERE id = '$id'";
$result = dbQuery($sql);

$sql = "UPDATE products SET size = size - 1 WHERE id = '$pid'";
$result = dbQuery($sql);
    }
    else{
exit();
    }
header("Location: index.php");

}

function addCategory()
{
    $cat       = $_POST['cat'];
    $name      = $_POST['name'];
    $weight    = $_POST['weight'];
    $av_weight = $_POST['av_weight'];
    $price     = $_POST['price'];
    $sale      = $_POST['sale'];
    $offer     = $_POST['offer'];
    
    $sql = "SELECT max(size) FROM products";
    $result = dbQuery($sql);
    if(dbNumRows($result) > 0){
$row = mysql_fetch_assoc($result);
extract($row);
$size = $size + 1;
    }
    else{
$size = 0;
    }

    $sql   = "INSERT INTO products(product, size, name, weight, av_weight, price, sale, offer) VALUES('$product','$size','$name','$weight','$av_weight','$price','$sale', '$offer')";
    $result = dbQuery($sql) or die('Cannot add category' . mysql_error());
    
    header('Location: index.php);              
}


?>

Link to comment
Share on other sites

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.