karthikanov24 Posted September 14, 2009 Share Posted September 14, 2009 hi In the following posted code(add products at admin side) i inserted the following lines of code, echo $images; at line 10 echo $mainimage; at line 14 echo $thumbnail; at line 15 echo $thumbnailpath; at line 56 echo $result; at line 58 I get error ,i cannot see the output.. what are the correct codes..?? function addProduct() { $catId = $_POST['cboCategory']; $name = $_POST['txtName']; $description = $_POST['mtxDescription']; $price = str_replace(',', '', (double)$_POST['txtPrice']); $qty = (int)$_POST['txtQty']; $images = uploadProductImage('fleImage', SRV_ROOT . 'images/product/'); echo $images; $mainImage = $images['image']; $thumbnail = $images['thumbnail']; echo $mainimage; echo $thumbnail; $sql = "INSERT INTO tbl_product (cat_id, pd_name, pd_description, pd_price, pd_qty, pd_image, pd_thumbnail, pd_date) VALUES ('$catId', '$name', '$description', $price, $qty, '$mainImage', '$thumbnail', NOW())"; $result = dbQuery($sql); header("Location: index.php?catId=$catId"); } /* Upload an image and return the uploaded image name */ function uploadProductImage($inputName, $uploadDir) { $image = $_FILES[$inputName]; $imagePath = ''; $thumbnailPath = ''; // if a file is given if (trim($image['tmp_name']) != '') { $ext = substr(strrchr($image['name'], "."), 1); //$extensions[$image['type']]; // generate a random new file name to avoid name conflict $imagePath = md5(rand() * time()) . ".$ext"; list($width, $height, $type, $attr) = getimagesize($image['tmp_name']); // make sure the image width does not exceed the // maximum allowed width if (LIMIT_PRODUCT_WIDTH && $width > MAX_PRODUCT_IMAGE_WIDTH) { $result = createThumbnail($image['tmp_name'], $uploadDir . $imagePath, MAX_PRODUCT_IMAGE_WIDTH); $imagePath = $result; } else { $result = move_uploaded_file($image['tmp_name'], $uploadDir . $imagePath); } if ($result) { // create thumbnail $thumbnailPath = md5(rand() * time()) . ".$ext"; echo $thumbnailpath; $result = createThumbnail($uploadDir . $imagePath, $uploadDir . $thumbnailPath, THUMBNAIL_WIDTH); echo $result; // create thumbnail failed, delete the image if (!$result) { unlink($uploadDir . $imagePath); $imagePath = $thumbnailPath = ''; } else { $thumbnailPath = $result; } } else { // the product cannot be upload / resized $imagePath = $thumbnailPath = ''; } } return array('image' => $imagePath, 'thumbnail' => $thumbnailPath); } Quote Link to comment https://forums.phpfreaks.com/topic/174178-how-to-get-the-output/ Share on other sites More sharing options...
Adam Posted September 14, 2009 Share Posted September 14, 2009 I get error ,i cannot see the output.. Can you elaborate on this? What do you see? Do you have errors disabled? Quote Link to comment https://forums.phpfreaks.com/topic/174178-how-to-get-the-output/#findComment-918185 Share on other sites More sharing options...
AviNahum Posted September 14, 2009 Share Posted September 14, 2009 what error you get? are you calling to these functions? Quote Link to comment https://forums.phpfreaks.com/topic/174178-how-to-get-the-output/#findComment-918186 Share on other sites More sharing options...
karthikanov24 Posted September 14, 2009 Author Share Posted September 14, 2009 hi this is processcategory file of a shopping cart in admin/product folder. when the admin add a product(name, description etc) in the add product form,and after clicking the "add product" button,this file gets into action I wish to see the values stored in $images,$mainimage,$thumbnail,$thumbnailpath etc..(to check what is stored..)as told in above.. eg. $a=5; i can see it using echo $a; I dont get errors...but i cannot see the value displayed when running the file or project...so could you give me the soultion... Quote Link to comment https://forums.phpfreaks.com/topic/174178-how-to-get-the-output/#findComment-918206 Share on other sites More sharing options...
karthikanov24 Posted September 14, 2009 Author Share Posted September 14, 2009 i can see the normal display of list of products that are added,but i cannot see the values that i tried to echo.. Quote Link to comment https://forums.phpfreaks.com/topic/174178-how-to-get-the-output/#findComment-918217 Share on other sites More sharing options...
karthikanov24 Posted September 14, 2009 Author Share Posted September 14, 2009 hi Please could u give me any solution to my above asked question ? Quote Link to comment https://forums.phpfreaks.com/topic/174178-how-to-get-the-output/#findComment-918361 Share on other sites More sharing options...
karthikanov24 Posted September 17, 2009 Author Share Posted September 17, 2009 hi can i know the reason why i am not getting any reply from you for my question..??? Quote Link to comment https://forums.phpfreaks.com/topic/174178-how-to-get-the-output/#findComment-920147 Share on other sites More sharing options...
Adam Posted September 17, 2009 Share Posted September 17, 2009 Despite the bark of orders to 'find the solution' for you, you've given a big chunk of fairly complex looking code (may well not be) with little explanation and no code to show how these functions are called.. that I'm sure no one *wants* to work their way through and find what your problem is.. without a little please and thank you at least. Quote Link to comment https://forums.phpfreaks.com/topic/174178-how-to-get-the-output/#findComment-920154 Share on other sites More sharing options...
DavidAM Posted September 17, 2009 Share Posted September 17, 2009 at the end of the function, you have header("Location: index.php?catId=$catId"); which is loading a new page, so the echo's are not staying on the screen long enough to be seen. You'll either have to echo to a log file and read it later, or comment out the header (for testing) and echo out an HTML link. Then you can read the screen, and then click the link to continue processing to the next page. Quote Link to comment https://forums.phpfreaks.com/topic/174178-how-to-get-the-output/#findComment-920191 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.