Jump to content

karthikanov24

Members
  • Posts

    54
  • Joined

  • Last visited

    Never

Everything posted by karthikanov24

  1. hi function formatCategories($categories, $parentId) { // $navCat stores all children categories // of $parentId $navCat = array(); // expand only the categories with the same parent id // all other remain compact $ids = array(); foreach ($categories as $category) { if ($category['cat_parent_id'] == $parentId) { $navCat[] = $category; } // save the ids for later use $ids[$category['cat_id']] = $category; } print_r($ids[$category[0]]); If i am printing the array using, print_r($ids[$category[0]]);here 0 is the start key of the array(as shown in last line of codes)..OR print_r($ids[$category[12]]); here 12 is the cat_id of a product... I am getting notice as,Notice: Undefined offset: 0. without out the display of expected output.. But if i use print_r($ids); i get, Array ( [12] => Array ( [cat_id] => 12 [cat_parent_id] => 0 [cat_name] => Cars [cat_image] => dce08605333d805106217aaab7f93b95.jpg [cat_description] => Expensive and luxurious cars ) [13] => Array ( [cat_id] => 13 [cat_parent_id] => 0 .................................etc.... And if i use print_r($ids[$category['cat_id']]);after for each loop i get, Array ( [cat_id] => 17 [cat_parent_id] => 13 [cat_name] => Hunter X Hunter [cat_image] => 746e05a7a629d53bc488115a75ee35d9.jpg [cat_description] => Story about hunter and combat ) The question is why do i get notice of undefined offset after using those,print_r($ids[$category[0]]);(as shown in last line of codes)..OR print_r($ids[$category[12]]); statements instead of expected output.. could you explain this please.. thanks karthikanov24
  2. hi array_multisort($parent); $parent displays the following array before multisorting...as follows.. Array ( [0] => Array ( [cat_id] => 15 [cat_parent_id] => 12 [cat_name] => Mercedes-Benz [cat_image] => e40c0b24095b3b5284cb5f64ab394b5a.jpg [cat_description] => Expensive but real good ) [1] => Array ( [cat_id] => 14 [cat_parent_id] => 12 [cat_name] => Volvo [cat_image] => 45ad4ebcdc58193534aabc6dc9c1a022.jpg [cat_description] => Swedish luxury car ) ) After using array_multisort() as shown in the code it displays as follows... Array ( [0] => Array ( [cat_id] => 14 [cat_parent_id] => 12 [cat_name] => Volvo [cat_image] => 45ad4ebcdc58193534aabc6dc9c1a022.jpg [cat_description] => Swedish luxury car ) [1] => Array ( [cat_id] => 15 [cat_parent_id] => 12 [cat_name] => Mercedes-Benz [cat_image] => e40c0b24095b3b5284cb5f64ab394b5a.jpg [cat_description] => Expensive but real good ) ) what has been changed here after using array_multisort() in the above array...? (how it is sorted..?) thanks karthikanov24
  3. hi what are the values of $i,the for loop takes and at what value of $i it enters the last if loop to print whether it leaves the for loop when $i reaches the value '1' or leaves after increasing to value '2'...? $categoryList = getCategoryList(); $categoriesPerRow = 3; $numCategory = count($categoryList); $columnWidth = (int)(100 / $categoriesPerRow); ?> <table width="100%" border="0" cellspacing="0" cellpadding="20"> <?php if ($numCategory > 0) { $i = 0; for ($i; $i < $numCategory; $i++) { if ($i % $categoriesPerRow == 0) { echo '<tr>'; } // we have $url, $image, $name, $price extract ($categoryList[$i]); echo "<td width=\"$columnWidth%\" align=\"center\"><a href=\"$url\"><img src=\"$image\" border=\"0\"><br>$name</a></td>\r\n"; if ($i % $categoriesPerRow == $categoriesPerRow - 1) { echo '</tr>'; } } if ($i % $categoriesPerRow > 0) { echo '<td colspan="' . ($categoriesPerRow - ($i % $categoriesPerRow)) . '"> </td>'; } } else {
  4. hi Is this correct...? if(count(getChildCategories($categories,$catId))>0) echo "have values"; else echo "empty"; Actually i want to check the value of getChildCategories() alone...and not others.. Please could you help me.... thanks karthikanov24
  5. hi In the above posting,there is no variable like $array .There is only function getChildCategories() having array..... so could you give the code using that function to check the value in it...please.. thanks karthikanov24
  6. hi $child = array_merge($child, getChildCategories($categories, $catId)); In the above line of code,the value(return value) of the function getChildCategories() is an array.... how to check(what debugging code is used) whether there is any value or in that function(or array) or it is null....? thanks karthikanov24
  7. hi I tried to find the urls relating to the questions that i posted above by typing , "<td width=\"$columnWidth%\" align=\"center\"><a href=\"" . $_SERVER['PHP_SELF'] . "?c=$catId&p=$pd_id" . "\"> in the google search bar in google website...... but i did'nt get the correct url that explains me these things told by you.. So could you say me,what words should be typed in google search,to get the correct urls that deals with my above question....please...?? and thanks for your answers.. karthikanov24
  8. hi in the following part of the above posted code, <a href=\''".$_SERVER'PHP_SELF']."?=$catId&p=$pd_id". "\"> If the double quotes are replaced by single quotes as follows,its not working... <a href=\'' ' .$_SERVER'PHP_SELF'].'?=$catId&p=$pd_id'. '\"> or <a href=\' ".$_SERVER'PHP_SELF']."?=$catId&p=$pd_id". "\'> or <a href=\' ' .$_SERVER'PHP_SELF'].'?=$catId&p=$pd_id'. '\'> why it so...? could you explain me with an example <a href> tag...please.. thanks karthikanov24
  9. hi <?php echo "<td width=\"$columnWidth%\" align=\"center\"><a href=\"" . $_SERVER['PHP_SELF'] . "?c=$catId&p=$pd_id" . "\"><img src=\"$pd_thumbnail\" border=\"0\"><br>$pd_name</a><br>Price : $pd_price"; ?> In the above line of php code, whats the function of those slashes (\) ..? why the slash is inside the double quotes,which is after c=$catID&p=$pd_id". thanks karthikanov24
  10. hi From where the global variable, $shopconfig which is inside the function displayAmount() gets the reference(value)..? Is it from the variable $shopconfig inside the config.php file or from the variable $shopconfig inside the function (which is above the function displayAmount()) getshopconfig() in common.php file...? thanks karthikanov24
  11. hi In the config file of my application,i have the following code, <?php require_once 'database.php'; require_once 'common.php'; // get the shop configuration ( name, addres, etc ), all page need it $shopConfig = getShopConfig(); ?> In the common.php file,i have the following codes: <?php require_once 'config.php'; require_once 'database.php'; function getShopConfig() { // get current configuration $sql = "SELECT sc_name, sc_address, sc_phone, sc_email, sc_shipping_cost, sc_order_email, cy_symbol FROM tbl_shop_config sc, tbl_currency cy WHERE sc_currency = cy_id"; $result = dbQuery($sql); $row = dbFetchAssoc($result); if ($row) { extract($row); $shopConfig = array('name' => $sc_name, 'address' => $sc_address, 'phone' => $sc_phone, 'email' => $sc_email, 'sendOrderEmail' => $sc_order_email, 'shippingCost' => $sc_shipping_cost, 'currency' => $cy_symbol); } else { $shopConfig = array('name' => '', 'address' => '', 'phone' => '', 'email' => '', 'sendOrderEmail' => '', 'shippingCost' => '', 'currency' => ''); } return $shopConfig; } function displayAmount($amount) { global $shopConfig; return $shopConfig['currency'] . number_format($amount); } Here inside the funtion displayAmount(),why $shopconfig is declared as global?whats the use of it..? thanks karthikanov24
  12. hi foreach() works only for array... Here whether $_POST is array?...if so where is it initialised as array.....? thanks karthikanov24
  13. hi what is the use of addslahes here... thanks karthikanov24
  14. hi This code is about configuration... Could you explain the following codes... if (!get_magic_quotes_gpc()) { if (isset($_POST)) { foreach ($_POST as $key => $value) { $_POST[$key] = trim(addslashes($value)); } } if (isset($_GET)) { foreach ($_GET as $key => $value) { $_GET[$key] = trim(addslashes($value)); } } } thanks karthikanov24
  15. hi The PASSWORD() is not user defined funtion,its mysql PASSWORD()...... so what should be done,please... thanks karthikanov24
  16. hi the PASSWORD( ) used in the following code, is used to take the newly added password from user to database function addUser() { $userName = $_POST['txtUserName']; $password = $_POST['txtPassword']; // check if the username is taken $sql = "SELECT user_name FROM tbl_user WHERE user_name = '$userName'"; $result = dbQuery($sql); if (dbNumRows($result) == 1) { header('Location: index.php?view=add&error=' . urlencode('Username already taken. Choose another one')); } else { $sql = "INSERT INTO tbl_user (user_name, user_password, user_regdate) VALUES ('$userName',PASSWORD('$password'), NOW())"; dbQuery($sql); header('Location: index.php'); } } But here in the admin login code as follow,the PASSWORD( ) is not working. If a call is made to this funtion it shows error as:UNDEFINED FUNCTION PASSWORD( ) function doLogin() { $userName = $_POST['txtUserName']; $password=$_POST['txtPassword']; // first, make sure the username & password are not empty if ($userName == '') { $errorMessage = 'You must enter your username'; } else if ($password == '') { $errorMessage = 'You must enter the password'; } else { // check the database and see if the username and password combo do match $sql = "SELECT user_id FROM tbl_user WHERE user_name = '$userName' AND user_password =PASSWORD('$password')"; $result = dbQuery($sql); what is the correct codes.....? Thanks karthikanov24
  17. hi when does the hashes while using password() changes and will the hashes change while using md5() ? thanks karthikanov24
  18. hi In the following code,what is the use of PASSWORD() and NOW() ? $sql = "INSERT INTO tbl_user (user_name, user_password, user_regdate) VALUES ('$userName',PASSWORD('$password'), NOW())"; thanks, karthikanov24
  19. hi may i know the reason ,why i am not getting the reply ?? Actually i want the codes that is to be putted inside that php file... thanks karthikanov24
  20. Could you say me which code is that..please..? Thanks, karthikanov24
  21. hi In the following php funtion code, function uploadproductimage() returns an array at line 77 of the below posting, to $images variable at line 10 in funtion addproduct(). If i use print_r ($images); or print_r($images['image']); etc.. (As we know that arrays should be printed using print_r) below the line of code in addproduct() as follows: $images = uploadProductImage('fleImage', SRV_ROOT . 'images/product/'); print_r($images) instead,if i use ,echo $image; i get the output of $image variable.. Could u give me the reason,please? <?php 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/'); $mainImage = $images['image']; $thumbnail = $images['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"; $result = createThumbnail($uploadDir . $imagePath, $uploadDir . $thumbnailPath, THUMBNAIL_WIDTH); // 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); } ?> Thanks, karthikanov24
  22. hi thanks...Is that the php file look like this say name of the php file is abc.php <?php $dest=imagecreatetruecolor($w,$h); echo $dest; ?> and <img src> tag is used in the following funtion which is in another file....like this...at line 12 ? function copyImage($srcFile, $destFile, $w, $h, $quality = 75) { $tmpSrc = pathinfo(strtolower($srcFile)); $tmpDest = pathinfo(strtolower($destFile)); $size = getimagesize($srcFile); if ($tmpDest['extension'] == "gif" || $tmpDest['extension'] == "jpg") { $destFile = substr_replace($destFile, 'jpg', -3); $dest = imagecreatetruecolor($w, $h); imageantialias($dest, TRUE); echo "<img src="abc.php">"; } elseif ($tmpDest['extension'] == "png") { $dest = imagecreatetruecolor($w, $h); imageantialias($dest, TRUE); } else { return false; } could u give me the exact codings thru an example, please.. Thanks, karthikanov24
  23. How and where can we use the following statement of html coding, <img src="<?php echo $dest;?>"> and <img src="<?php eho $src;?>"> to get or see the image inside the php codes posted below <?php function copyImage($srcFile, $destFile, $w, $h, $quality = 75) { $tmpSrc = pathinfo(strtolower($srcFile)); $tmpDest = pathinfo(strtolower($destFile)); $size = getimagesize($srcFile); if ($tmpDest['extension'] == "gif" || $tmpDest['extension'] == "jpg") { $destFile = substr_replace($destFile, 'jpg', -3); $dest = imagecreatetruecolor($w, $h); imageantialias($dest, TRUE); } elseif ($tmpDest['extension'] == "png") { $dest = imagecreatetruecolor($w, $h); imageantialias($dest, TRUE); } else { return false; } echo $dest; switch($size[2]) { case 1: //GIF $src = imagecreatefromgif($srcFile); break; case 2: //JPEG $src = imagecreatefromjpeg($srcFile); break; case 3: //PNG $src = imagecreatefrompng($srcFile); break; default: return false; break; } imagecopyresampled($dest, $src, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); switch($size[2]) { case 1: case 2: imagejpeg($dest,$destFile, $quality); break; case 3: imagepng($dest,$destFile); } return $destFile; } ?> ------------- Thanks, Karthikanov24
×
×
  • 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.