Jump to content

envexlabs

Members
  • Posts

    256
  • Joined

  • Last visited

    Never

Everything posted by envexlabs

  1. akitchin said it best. If you have a basic knowledge of AJAX it shouldn't be to hard to complete.
  2. There is a pretty in-depth tutorial here: http://www.webmonkey.com/webmonkey/03/40/index0a.html It explains using PHP, mySQL and Flash. hope it helps!
  3. Hey, I am pulling a value from a database that looks like this: /uploads/images/picture.jpg How would i go about getting just the .jpg? Thanks, envex
  4. Just set a CSS class for image1. I'm not to sure the code, but google should find it no problem. Opacity
  5. i think your missing a variable $query = "insert into site_stats_bots (User_ID, clicks, Timestamp) values ('$User_ID', '1', '$Timestamp_today' )"; $result = mysql_query($query); }
  6. Hey, I have an uploader that uploads an image, then lets the user crop it to the size they want. If the user uploads an image 800 x 600, and i set the height to 400 and width to 300, when i goto crop it, it screws everything up and renders out a solid color. Anyone understand and possibly offer some help? Thanks, envex
  7. Hey, It's not ajax at all, it's just a little javascript and CSS http://www.askthecssguy.com/2007/03/form_field_hints_with_css_and.html It will just take a little editing to get it to look they way you want.
  8. Hey, adding method="post" didn't work, so i made a new thread in the AJAX forums. Thanks for all your help! envex
  9. Hey, I have an image upload script that i'm trying to execute via AJAX, but my browser is giving me this error in the JS Console: Warning: Form contains enctype=multipart/form-data, but does not contain method=post. Submitting normally with method=GET and no enctype instead. Source File: http://*********.com/store.php?store_id=1 Line: 0 my ajax.js file: //AJAX POST var http_request = false; function makePOSTRequest(url, parameters) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { // set type accordingly to anticipated content type //http_request.overrideMimeType('text/xml'); http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open('POST', url, true); http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request.setRequestHeader("Content-length", parameters.length); http_request.setRequestHeader("Connection", "close"); http_request.send(parameters); slide_product(); } function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { result = http_request.responseText; document.getElementById('store_contents').innerHTML = result; } else { alert('There was a problem with the request.'); } } } function get(obj) { var poststr = "pname=" + encodeURI( document.getElementById("pname").value ) + "&price=" + encodeURI( document.getElementById("price").value ) + "&desc=" + encodeURI( document.getElementById("desc").value ) + "&cat_id=" + encodeURI( document.getElementById("cat_id").value ) + "&pic=" + encodeURI( document.getElementById("pic").value ) + "&store_id=" + encodeURI( document.getElementById("store_id").value ); makePOSTRequest('inc/ajax/add_product.php', poststr); alert(poststr); } Does anyone know how to fix this?
  10. Hey, It looks like my AJAX script is screwing everything up. I'm getting this error when i execute the form: Warning: Form contains enctype=multipart/form-data, but does not contain method=post. Submitting normally with method=GET and no enctype instead. Source File: http://werehavingasale.com/store.php?store_id=1 Line: 0 It looks like my browser is reverting to GET even though the AJAX function is using POST. anyone know AJAX around here?
  11. get is just the name of the AJAX function. It's still using POST to get all the form elements
  12. We are slowly making progress var_dump(is_file($_FILES['userfile']['name'])) . "\n"; <-- returning false var_dump(is_dir($uploaddir)) . "\n"; <--returning true so the folder is recognized! here is my form code: <form action="javascript:get(document.getElementById(\'add_product\'));" name="add_product" enctype="multipart/form-data" id="add_product"> <p>Product Name:</p> <p><input type="text" id="pname" name="pname" class="reg" /></p> <p>Price:</p> <p><input type="text" id="price" name="price" class="reg" /></p> <p>Description:</p> <p><textarea id="desc" name="desc" cols="40" rows="3" class="edit_text" wrap="soft" onkeydown="textCounter(this.form.desc, this.form.remLen,100);" onkeyup="textCounter(this.form.desc, this.form.remLen,100); "></textarea></p> <input type="hidden" id="store_id" name="store_id" value="' . $store_id . '" /> <input type="hidden" id="cat_id" name="cat_id" value="' . $cat_id . '" /> <p><input name="remLen" type="text" id="remLen" value="100" size="3" maxlength="3" readonly class="remLen" /> characters remaining.</p> <p>Product Image:</p> <p><input name="userfile" id="userfile" type="file" /></p> <p><input type="image" src="images/add_product.gif" name="button" value="Submit"></p></form> I am on mediatemple running PHP Version 4.4.7
  13. Hey, input file is named 'userfile', tripled checked that this s that i'm getting: [HTTP_POST_FILES] => Array ( ) [_FILES] => Array ( ) [_REQUEST] => Array ( [pname] => 123 [price] => 123 [desc] => 123 [cat_id] => 2 [userfile] => /Library/Application Support/Apple/iChat Icons/Planets/Neptune.gif [store_id] => 1 [bX] => a378nih37geu1&b=3&s=49 [phpSESSID] => 2655bb58e7be9d99100888e8eb2dd687 [amember_nr] => 9c5c925fcbe08ada07718365a0547d54 ) [store_id] => 1 [pname] => 123 [price] => 123 [desc] => 123 [cat_id] => 2 [uploadfile] => uploads/product_images/1. [pic] => uploads/product_images/1. [add_product_query] => 1 [product] => [owner] => ) So i'm not getting the extension, and it's not moving the uploaded file.
  14. Hey, Alright, so it's still not working. i think $_FILES is still blank :S
  15. i added enctype="multipart/form-data" to the form, now i just have to work out some variable issues. will post soon! thanks, envex
  16. Ok, so i think i'm getting closer to figuring this out. $_FILES['userfile']['name'] is returning nothing. anyone know why?
  17. Hey, I'm having a problem with my image uploader. Here is the file structure: root/inc/php/php_functions.php root/inc/ajax/add_product.php root/uploads php_functions.php upload function: function upload_image($upload_dir, $store_pic_id){ global $uploadfile; //grabs the file extension $file_ext = explode(".",$_FILES['userfile']['name']); //puts the array into a variable so that it can be inputed into the database as a name.ext instead of Array[] $name = $store_pic_id . '.' . $file_ext[1]; //sets the directory and name for the file $uploaddir = 'uploads/'. $upload_dir .'/'; $uploadfile = $uploaddir . basename($name); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {} else { echo "Picture could not be uploaded"; } //changes the permissions of the file chmod($upload_dir .'/' . $name . '', 0644); } add_product.php: <?php include'../php/config.php'; include'../php/php_functions.php'; echo '<p>'; $store_id = $_POST[store_id]; $pname = $_POST[pname]; $price = $_POST[price]; $desc = $_POST[desc]; $cat_id = $_POST[cat_id]; upload_image('product_images', $member_info[0]); $pic = $uploadfile; $add_product_query = mysql_query("INSERT INTO `products` (`product_id`, `store_id`, `name`, `price`, `sale_price`, `pic`, `description`, `display`, `on_sale`, `catagory`) VALUES (NULL, '$store_id', '$pname', '$price', '0', '$pic', '$desc', '1', '0', '$cat_id')") or die(mysql_error()); display_products($store_id, $cat_id); echo '</p>'; ?> I am getting this error when i try to upload it: Picture could not be uploaded Warning: chmod() [function.chmod]: No such file or directory in /mnt/gs02/herd02/20143/domains/werehavingasale.com/html/inc/php/php_functions.php on line 398 I know the function works because i use it on a file that is located in the root, but why isn't working when i use it in a file deep in the structure? Thanks, envex
  18. Hey, i have product87, i just want 87. how do i do this? Thanks, envex
  19. Hey, It doesn't look like you have any code grabbing the page=picture.php, which would be a $_GET , if echo'd would be picture.php You could set different variables and use an if: $test = $_GET if($test == "one") { $picture = "matt.jpg"; }else{} Then $picture would have a value of matt.jpg It just looks like your trying to pass a variable that isn't being defined.
  20. Hey, I think it has something to do with setting POST variables into your SESSIONS, and refreshing using PHP_SELF.
  21. I'm trying to add some drag and drop functionality to a site i'm developing, but i'm having some troubles. I have some catagory buttons, and some products. You can drag the products, and when you drop them on a certain catagory, an AJAX function changes the catagory of the selected product. The problem i am having is that i dont know how to grab the product ID and the catagory ID depending on what has been dragged and dropped. Here is some code: Renders out the products function display_products($store_id, $catagory_id){ $store_id = mysql_escape_string($store_id); //displays the what's hot if cat_id = 0 if($catagory_id == 0) { $product_info_query = mysql_query('SELECT * FROM `products` WHERE store_id = ' . $store_id . ' & display = 1 LIMIT 0, 12'); }else{ //displays the chosen catagory $product_info_query = mysql_query('SELECT * FROM `products` WHERE store_id = ' . $store_id . ' & `catagory` = ' . $catagory_id . ' & display = 1 LIMIT 0, 12'); } while($product = mysql_fetch_row($product_info_query)) { echo ' <!-- START PRODUCT --> <div class="product_container" id="product' . $product[0] . '"> <div class="product_info"> <p class="fstore_name">' . $product[2] . '</p> <p class="product_price">Price: $' . $product[3] . ' '; on_sale(); echo'<p class="fstore_content">' . $product[6] . '</p> <div class="sub_links"> <p class="nav_images"><img src="images/icons/page_white_add.gif" height="16px" width="16px" alt="" /><a href="#">add to shopping list</a></p> </div> <!-- sub_links div --> </div> <!-- product_info div --> <div class="product_img_border"> <div class="product_img" style="background: url(uploads/product_images/' . $product[5] .'.jpg);"> </div> <!-- product_img --> </div> <!-- product_img_border -->'; product_edit_nav($product[0]); echo '</div> <!-- product_container div --> <script type="text/javascript"> new Draggable(\'product' . $product[0] . '\',{revert:true}); </script> <!-- END PRODUCT -->'; } } Renders out the catagories function display_catagories($owner_id, $store_id){ $display_cat_query = mysql_query('SELECT * FROM `catagories` WHERE `owner_id` = \'' . $owner_id . '\''); while($cat_info = mysql_fetch_row($display_cat_query)){ echo '<div class="catagorie_button" id="cat_cont' . $cat_info[0] . '"><a href="?store_id=' . $store_id .'&cat=' . $cat_info[0] . '">' . $cat_info[2] . '</a></div>'; echo'<script type="text/javascript"> Droppables.add(\'cat_cont' . $cat_info[0] . '\', { onDrop: function(){change_cat(\'product87\',\'inc/ajax/edit_cat.php?state=approve\');} }); </script>'; } } Any help would be great! envex
  22. Thanks, Will take a look through it
  23. on last chance, before i just let the thread die.
×
×
  • 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.