Jump to content

tahakirmani

Members
  • Posts

    27
  • Joined

  • Last visited

tahakirmani's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello I am using jQzoom in my HTML page to view images in Slider. I am having problem in showing 'smallimages' and 'largeimages'. Its working fine for 'Thumb image' because it has <img src> tag with it, but small image and large image doesn't have <img src> tag and I am unable to understand how to resize image in both 'smallimage:' &'largeimage:'. Following is the code i am working on. <link rel="stylesheet" href="css/jquery.jqzoom.css" type="text/css"> <script type="text/javascript"> $(document).ready(function() { $('.jqzoom').jqzoom({ zoomType: 'innerzoom', preloadImages: false, alwaysOn:false }); }); </script> <table width="600" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td align="right" valign="top" ><div class="clearfix" style=";"> <a href="images/imgProd2/bracelets_Diamond.png" class="jqzoom" rel='gal1' title="triumph" > <img src='<?php echo $single_image_query_fetch['images']; ?>' height='261' width='325' title='triumph' style='border: 4px solid #666;'> </a> </div> <br/> <!-------------------------------- Images Part is strating from here -------------------------> <div class="clearfix" style="; margin-top:-10px;" > <ul id="thumblist" class="clearfix" > $image_query = "select * from product_images where product_id=$id"; $image_query_run = mysql_query($image_query); while( $image_query_fetch = mysql_fetch_array($image_query_run)) { //Thumb $thumb_image = "<img src=http://localhost/cms/". $image_query_fetch['images'] ." height='80' width='100' alt=\"\" />"; //large $big_image = "<img src=http://localhost/cms/". $image_query_fetch['images'] ." height='1024' width='1280' alt=\""/>"; $image_fetch[1]= $big_image; //small $small_image = "<img src=http://localhost/cms/". $image_query_fetch['images'] ." height='261' width='325' alt=\"\" />"; <li> <a href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: 'images/imgProd2/Bracelet_Silver.png', largeimage: 'images/imgProd2/bracelets_Diamond.png'}"> <img src='<?php echo $image_fetch[0]; ?>' height='80' width='100' > </a> </li> } Thanks
  2. I am trying to update 3 images of same product_id. I have a different product_table and Product_images table. The product_images table has 5 fields; image_id, product_id, name, images, ord. I am trying to update images for any specific product_id. The problem I was facing before was that it set the same 'Image' for all of the three 'images', that why I add 'ord' filed and it solver that problem. Now I have a new problem. I am unable to understand where to write update image' query. If I write it inside for loop then it runs 'Update Query' 6 times and if I write it outside for loop then its unable to find out $ord[] variable. Kindly tell the way to resolve this problem. Given below is the part of code I am working on. /* * ------------------- IMAGE-QUERY Test 002 -------------------- */ if (isset ( $_FILES ['files'] ) || ($_FILES ["files"] ["type"] == "image/jpeg")) { $i = 1; /* * ----------------------- Taking Current Order_id ------------------------ */ // $order_sql= "select MAX(ord) from product_images"; $order_sql = "SELECT ord from product_images where product_id=$id"; $order_sql_run = mysql_query ( $order_sql ); echo mysql_error (); for($i = 1; $i <= $order_fetch = mysql_fetch_array ( $order_sql_run ); $i ++) // while ($order_fetch= mysql_fetch_array($order_sql_run)) {) echo 'ID ' . $order_id [$i] = $order_fetch [(ord)]; } /* * ----------------------- Taking Current Order_id ------------------------ */ foreach ( $_FILES ['files'] ['tmp_name'] as $key => $tmp_name ) { // echo $tmp_name."<br>"; // echo 'number<br>'; echo $image_name = $_FILES ["files"] ["name"] [$key]; $random_name = rand () . $_FILES ["files"] ["name"] [$key]; $folder = "upload/products/" . $random_name; move_uploaded_file ( $_FILES ["files"] ["tmp_name"] [$key], "upload/products/" . $random_name ); echo '<br>'; echo $sql = "update product_images set name= '$random_name',images= '$folder' where product_id=$id andord=$order_id[$i]"; if ($query_run = mysql_query ( $sql )) { echo '<br>'; echo 'Done'; } else { echo mysql_error (); } // $i=$i+1; } } /*------------------- IMAGE-QUERY Test 002 --------------------*/
  3. Hello I have written the following code to update Images that are stored in Files. The code is working perfectly when I am using it to Upload images, but when I use it to Update Images, it is giving me 'Invalid file' error message. It is getting problem in the first 'if' statement and directly going to its else statement message 'Invalid File'. Kindly check it and guide me. Thanks <?php var_dump($_REQUEST); session_start(); error_reporting(E_PARSE); if (isset ($_SESSION['username']) ) { //echo "<div id='nav'"; echo "<ul><hr> <li><a href='insert_product.php' >Add Product | </a></li> <li><a href='add_category.php'> Add Category </a></li> <li><a href='sub_categories.php'> Add Sub-Category </a></li> <li><a href = 'view_products.php' >View All Products</a> </li> <li><a href = 'all_categories.php' >View All Categories</a> </li> <li><a href='view_all_sub_categories.php'>View All Sub Categories</a></li> </ul></hr>"; include 'connect.php'; $category_id= $_GET['category_id']; $query= "select * from category where category_id= $category_id"; $query_run= mysql_query($query); $fetch= mysql_fetch_array($query_run); $name= $fetch['name']; echo " <form action='update_category.php?category_id=$category_id' method='POST' > <table border=1> <tr><td> Category Name:</td><td><input type='text' name='category' value='$name' /> </td></tr> <tr><td> Image1:</td><td> <input type='file' name= 'image' > </td></tr> <tr><td> <input type='submit' value='Update' /> </td></tr> </form> </table> "; echo "<form action='delete_category.php?category_id=$category_id' method='POST'> <input type='submit' value='Delete'> </form> "; if (isset($_POST['category']) ) { $category_name = $_POST['category']; $query_update="UPDATE category SET name = '$category_name' WHERE category_id =$category_id "; if (mysql_query($query_update)) { echo "Records updated"; } else { echo mysql_error(); } /*------------------- IMAGE QUERY --------------------*/ $allowedExts = array("gif", "jpeg", "jpg", "png"); $extension = end(explode(".", $_FILES["image"]["name"])); if ((($_FILES["image"]["type"] == "image/gif") || ($_FILES["image"]["type"] == "image/jpeg") || ($_FILES["image"]["type"] == "image/jpg") || ($_FILES["image"]["type"] == "image/pjpeg") || ($_FILES["image"]["type"] == "image/x-png") || ($_FILES["image"]["type"] == "image/png")) //&& ($_FILES["file"]["size"] < 200000) && in_array($extension, $allowedExts)) { if ($_FILES["image"]["error"] > 0) { echo "Return Code: " . $_FILES["image"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["image"]["name"] . "<br>"; echo "Type: " . $_FILES["image"]["type"] . "<br>"; echo "Size: " . ($_FILES["image"]["size"] / 200000) . " kB<br>"; $image_name= $_FILES["image"]["name"]; $random_name= rand().$_FILES["image"]["name"]; $path= move_uploaded_file($_FILES["image"]["tmp_name"], "upload/categories/" . $random_name); $folder="upload/categories/" .$random_name; echo "Stored in: "."upload/categories/". $random_name; echo $sql= "update category_images set name='$image_name' , location='$folder' where category_id= $category_id "; $result = mysql_query($sql); if ($result) { echo "successfull"; } else { echo mysql_error(); } } } else { echo "Invalid file". $_FILES["image"]["error"]; } /*----------------- IMAGE QUERY END ------------------*/ } /* echo $sql= "update category_images set name='$image_name' , location='$folder' where category_id= $category_id "; */ } else { echo "You Must need to Log in to Visit this Page"; } ?>
  4. /*-------------------IMAGE QUERY ---------------*/ $allowedExts = array("gif", "jpeg", "jpg", "png"); $extension = end(explode(".", $_FILES["files"]["name"])); if ((($_FILES["files"]["type"] == "image/gif") || ($_FILES["files"]["type"] == "image/jpeg") || ($_FILES["files"]["type"] == "image/jpg") || ($_FILES["files"]["type"] == "image/pjpeg") || ($_FILES["files"]["type"] == "image/x-png") || ($_FILES["files"]["type"] == "image/png")) //&& ($_FILES["file"]["size"] < 200000) && in_array($extension, $allowedExts)) { if ($_FILES["files"]["error"] > 0 ) { echo "Return Code: " . $_FILES["files"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["files"]["name"] . "<br>"; echo "Type: " . $_FILES["files"]["type"] . "<br>"; echo "Size: " . ($_FILES["files"]["size"] / 200000) . " kB<br>"; $image_name= $_FILES["files"]["name"]; $random_name= rand().$_FILES["files"]["name"]; $path= move_uploaded_file($_FILES["files"]["tmp_name"], "upload/products/" . $random_name); /* $path2= move_uploaded_file($_FILES["image2"]["tmp_name"], "upload/products/" . $random_name); $path3= move_uploaded_file($_FILES["image3"]["tmp_name"], "upload/products/" . $random_name); */ $folder="upload/products/" .$random_name; // $folder2="upload/products/" .$random_name; // $folder3="upload/products/" .$random_name; //echo "Stored in: " . "upload/" .rand(). $_FILES["file"]["name"]; echo "Stored in: "."upload/products/". $random_name; /* $sql = "INSERT INTO `category_images` (`image_name`,`image_location`) VALUES ('".$image_name."', '".$path."')"; */ $sql = "Insert into product_images (product_id,name,images) VALUES ($current_id,'$image_name', '$folder')"; $sql2 = "Insert into product_images (product_id,name,images) VALUES ($current_id,'$image_name2', '$folder2')"; $sql3 = "Insert into product_images (product_id,name,images) VALUES ($current_id,'$image_name3', '$folder3')"; $result = mysql_query($sql); //mysql_query($sql2); //mysql_query($sql3); if ($result) { echo "successfull"; } else { echo mysql_error(); } } } else { echo "Invalid file"; } /*----------------- IMAGE QUERY END ------------------*/
  5. Thank you so much for the guidance and help. I have watched the video and checked the other tutorial too. Now I have written the following code and its giving me a new error message. I Have updated my code. Kindly check it and guide me. Thanks.
  6. I am trying to upload multiple files from HTML form to a folder and storing information in my database. I have written the following code, but it is not working correctly. If I upload 1 image and left the other two Image fields,then it stores 3 images of same name and same Image and if I upload 3 different Images in three difference fields then it takes only the last image and replace others with it, and shows the same image for all. In Simple the problem is that it is still uploading just 1 file, but now its entring data 3 times in database. Kindly guide me. HTML Image Fields <file> <Image2> <Image3> /*------------------- IMAGE QUERY ---------------*/ $allowedExts = array("gif", "jpeg", "jpg", "png"); $extension = end(explode(".", $_FILES["file"]["name"])); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["image2"]["type"] == "image/gif") || ($_FILES["image3"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["image2"]["type"] == "image/jpeg") || ($_FILES["image3"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["image2"]["type"] == "image/jpg") || ($_FILES["image3"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/pjpeg") || ($_FILES["image2"]["type"] == "image/pjpeg") || ($_FILES["image3"]["type"] == "image/pjpeg") || ($_FILES["file"]["type"] == "image/x-png") || ($_FILES["image2"]["type"] == "image/x-png") || ($_FILES["image3"]["type"] == "image/x-png") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["image2"]["type"] == "image/png") || ($_FILES["image3"]["type"] == "image/png")) //&& ($_FILES["file"]["size"] < 200000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0 && $_FILES["image"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br>"; echo "Type: " . $_FILES["file"]["type"] . "<br>"; echo "Size: " . ($_FILES["file"]["size"] / 200000) . " kB<br>"; echo "Upload: " . $_FILES["image2"]["name"] . "<br>"; echo "Type: " . $_FILES["image2"]["type"] . "<br>"; echo "Size: " . ($_FILES["image2"]["size"] / 200000) . " kB<br>"; $image_name= $_FILES["file"]["name"]; $random_name= rand().$_FILES["file"]["name"]; $image_name2= $_FILES["image2"]["name"]; $random_name2= rand().$_FILES["image2"]["name"]; $image_name3= $_FILES["image3"]["name"]; $random_name3= rand().$_FILES["image3"]["name"]; $path= move_uploaded_file($_FILES["file"]["tmp_name"], "upload/products/" . $random_name); $path2= move_uploaded_file($_FILES["image2"]["tmp_name"], "upload/products/" . $random_name); $path3= move_uploaded_file($_FILES["image3"]["tmp_name"], "upload/products/" . $random_name); $folder="upload/products/" .$random_name; $folder2="upload/products/" .$random_name; $folder3="upload/products/" .$random_name; //echo "Stored in: " . "upload/" .rand(). $_FILES["file"]["name"]; echo "Stored in: "."upload/products/". $random_name; /* $sql = "INSERT INTO `category_images` (`image_name`,`image_location`) VALUES ('".$image_name."', '".$path."')"; */ $sql = "Insert into product_images (product_id,name,images) VALUES ($current_id,'$image_name', '$folder')"; $sql2 = "Insert into product_images (product_id,name,images) VALUES ($current_id,'$image_name2', '$folder2')"; $sql3 = "Insert into product_images (product_id,name,images) VALUES ($current_id,'$image_name3', '$folder3')"; $result = mysql_query($sql); mysql_query($sql2); mysql_query($sql3); if ($result) { echo "successfull"; } else { echo mysql_error(); } } } else { echo "Invalid file"; } /*----------------- IMAGE QUERY END ------------------*/
  7. I am trying to save images in my database from HTML form. I have written PHP code to accomplish this task. Its giving me the following error message,and not inserting data in the database. Kindly check it. Here i am sharing a excerpt from my code. I am using BLOB for image. /*------------------- IMAGE QUERY ---------------*/ $file =$_FILES['image']['tmp_name']; if(!isset($file)) { echo 'Please select an Image'; } else { $image_check= getimagesize($_FILES['image']['tmp_name']); if($image_check==false) { echo 'Not a Valid Image'; } else { $image =file_get_contents ($_FILES['image']['tmp_name'] ); $image_name =$_FILES['image']['name']; if ($image_query =mysql_query ("insert into product_images values (1,'$image_name',$image )")) { echo $current_id; //echo 'Successfull'; } else { echo mysql_error(); } } } /*----------------- IMAGE QUERY END ---------------------*/ <form action='insert_product.php' method='POST' enctype='multipart/form-data' ></br> File : <input type='file' name= 'image' > </form> Error Message
  8. Hello I am trying to insert values in my database from a dynamic drop down list. I have created the following program, its not given me any error message, but also its not inserting any record in database. Kindly check it and tell me where is the problem. I have also echo the fields which i am inserting in database, and all the fields are entering correctly in variables. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> </body> </html> <?php session_start(); if(isset($_SESSION['username'])) { include 'connect.php'; $select_query= 'Select * from category'; $select_query_run = mysql_query($select_query); echo " <form action='insert_product.php' method='POST' ></br> Product Name: <input type='text' name='product_name' /></br> Price : <input type= 'text' name= 'price' /></br> Description : <input type='text' name='description' />*Seperate by Comma</br> "; // Drop Down Display echo "<select name='category'>"; while ($select_query_array= mysql_fetch_array($select_query_run) ) { echo "<option value='".$select_query_array['category_id']."' >". htmlspecialchars($select_query_array["name"])."</option>"; } $selectTag= "<input type='submit' value='Insert' /></select></form>"; echo $selectTag; //Drop Down End! if(isset($_POST['product_name']) && isset($_POST['price']) && isset($_POST['description']) ) { echo $product_name = $_POST['product_name']; echo $price = $_POST['price']; echo $description = $_POST['description']; echo $category = $_POST['category']; //Problem Area $query= "insert into products (name, price, description, category_id ) VALUES( '$product_name', $price, '$description', $category )"; if($query_run= mysql_query($query)) { echo 'Data Inserted'; } else { 'Error In SQL'.mysql_error(); } } else { echo 'empty Field'; } } else { echo 'You Must Log in To View this Page!'; } ?>
  9. My Above mention problem has been solved, and now i am facing a new problem. I am trying to print all the images which are in database. I am using the following code and its printing out the code of images but not images when i am using header function its giving me an error message. Kindly tell me where to use the header function. <?php mysql_connect('localhost','root',''); mysql_select_db('a_database'); //$current_id= $_SESSION['user_id']; $query= "SELECT * FROM email_images where id=1" ; $query_run= mysql_query($query); while ($result= mysql_fetch_assoc($query_run)) { $result=$result['name']; //foreach ($result as $output) { // echo $output; echo $result; } ?>
  10. Hi, There are 10 records in my table who have id=10, I am trying to print all the records from this table where id=1. I have written the following code, but it is showing only the last inserted record not all the records. I used foreach loop and it starts giving me an error message. Thanks, Taha.
  11. Thank You so Much again !!! It is working now
  12. INSERT INTO email_images VALUES ('1', 'ÿØÿà\0JFIF\0.................................... , 'F:\\xampp\\tmp\\php6DE3.tmp') where `id`=1 *.....its too long text.
  13. Hi, I am creating a small PHP program where a user enter his username and password, and his profile opens, where he can upload his Pictures. I have written the following code for uploading image, where i am using SESSION variable to INSERT image data in Mysql Table. Its giving me an error message when i am using SESSION variable, if i use normal number in ID field it inserts a record. Kindly check it and help me in pointing out the error. <form acton="users_images.php" method='POST' enctype="multipart/form-data" > FILE: <input type="FILE" name="image"> <input type="submit" value="Upload Image"> </form> <?php include "core.php"; mysql_connect('localhost','root','' ); mysql_select_db('a_database'); $file= $_FILES['image']['tmp_name']; if(!isset($file)) { echo "Please Upload an Image"; }else { $image= mysql_real_escape_string(file_get_contents ($_FILES['image']['tmp_name'])); $image_name= mysql_real_escape_string($_FILES['image']['name']); $image_size= getimagesize($_FILES['image']['tmp_name']); $image_temp_loc= mysql_real_escape_string($_FILES['image']['tmp_name']); $current_id= $_SESSION['user_id']; if ($image_size==FALSE){ echo "Invalid Image"; }else { $query= "INSERT INTO email_images VALUES ('$current_id', '$image', '$image_temp_loc') where `id`=".$_SESSION['user_id']. "" ; //successfull //$query= "INSERT INTO email_images VALUES ('', '$image', '$image_temp_loc')" ; if (!$query_run=mysql_query($query)){ echo "Query Unsuccessful ".mysql_error(); } else { echo "successful"; } } } ?> ERROR MESSAGE :- Thanks, Taha.
×
×
  • 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.