jwk811 Posted February 15, 2007 Share Posted February 15, 2007 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"); } Quote Link to comment Share on other sites More sharing options...
fert Posted February 15, 2007 Share Posted February 15, 2007 $sql = "UPDATE products SET size += 1 WHERE id = '$id'; there's your problem Quote Link to comment Share on other sites More sharing options...
papaface Posted February 15, 2007 Share Posted February 15, 2007 ^^ that didnt help much. It should be: $sql = "UPDATE products SET size += 1 WHERE id = '$id'"; Quote Link to comment Share on other sites More sharing options...
jwk811 Posted February 15, 2007 Author Share Posted February 15, 2007 what? thats exactly what i have... Quote Link to comment Share on other sites More sharing options...
jwk811 Posted February 15, 2007 Author Share Posted February 15, 2007 oh i see now thanks! Quote Link to comment Share on other sites More sharing options...
jwk811 Posted February 15, 2007 Author Share Posted February 15, 2007 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); } ?> Quote Link to comment Share on other sites More sharing options...
papaface Posted February 15, 2007 Share Posted February 15, 2007 on what line? Quote Link to comment Share on other sites More sharing options...
jwk811 Posted February 15, 2007 Author Share Posted February 15, 2007 line 119 but i get this error a lot and its always the last line that it says but not really.. this error doesnt help you out you have to find it.. i thought it had something to do with the brackets anywhere.. do you see any mistakes with that? Quote Link to comment Share on other sites More sharing options...
papaface Posted February 15, 2007 Share Posted February 15, 2007 at the bottom: this header('Location: index.php); } ?> should be: header('Location: index.php'); } ?> Quote Link to comment Share on other sites More sharing options...
jwk811 Posted February 15, 2007 Author Share Posted February 15, 2007 thanks that must have been it but now the page is loading blank and shows the little yellow error signal in the left bottom corner of the page.. dont i have the worst problems? lol Quote Link to comment Share on other sites More sharing options...
papaface Posted February 15, 2007 Share Posted February 15, 2007 Put this error_reporting(E_ALL); ini_set('display_errors', '1'); at the top of your page and reload the page, if no errors are displayed, then there is nothing wrong with the code. Quote Link to comment Share on other sites More sharing options...
AndyB Posted February 16, 2007 Share Posted February 16, 2007 thanks that must have been it but now the page is loading blank and shows the little yellow error signal in the left bottom corner of the page.. dont i have the worst problems? lol That's a javascript error, surely. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.