Search Results

Search found 4 results on 1 pages for 'bluemagica'.

Page 1/1 | 1 

  • How to write php->mysql queries?

    - by Bluemagica
    Is there any good tutorial that has all the basic rules for writing queries to store $_Post vars from php to mysql? Like when to use backticks and singleqoutes, and how to safely write code with functions like get_magic_quotes_gpc()? Another thing is, assuming there is no javascript validation(since the user can easily turn it off), how should I handle empty form fields being sent as empty $_post variables and throwing errors? Do I have to use isset() call on all the post variables? What is the best way to handle users turning off javascript validation on a form?

    Read the article

  • image upload problem.

    - by Bluemagica
    I wrote a function to resize and upload images...it works, but only for one image. So if I call the function three times, I end up with 3 copies of the last image..... function uploadImage($name,$width,$height,$size,$path='content/user_avatars/') { //=================================================== //Handle image upload $upload_error=0; //Picture $img = $_FILES[$name]['name']; if($img) { $file = stripslashes($_FILES[$name]['name']); $ext = strtolower(getExt($file)); if($ext!='jpg' && $ext!='jpeg' && $ext!='png' && $ext!='gif') { $error_msg = "Unknown extension"; $upload_error = 1; return array($upload_error,$error_msg); } if(filesize($_FILES[$name]['tmp_name'])>$size*1024) { $error_msg = "Max file size of ".($size*1024)."kb exceeded"; $upload_error = 2; return array($upload_error,$error_msg); } $newFile = time().'.'.$ext; resizeImg($_FILES[$name]['tmp_name'],$ext,$width,$height); $store = copy($_FILES[$name]['tmp_name'],$path.$newFile); if(!$store) { $error_msg = "Uploading failed"; $upload_error = 3; return array($upload_error,$error_msg); } else { return array($upload_error,$newFile); } } } //========================================================================================= //Helper Functions function getExt($str) { $i = strpos($str,"."); if(!$i) { return ""; } $l = strlen($str)-$i; $ext = substr($str,$i+1,$l); return $ext; } function resizeImg($file,$ext,$width,$height) { list($aw,$ah) = getimagesize($file); $scaleX = $aw/$width; $scaleY = $ah/$height; if($scaleX>$scaleY) { $nw = round($aw*(1/$scaleX)); $nh = round($ah*(1/$scaleX)); } else { $nw = round($aw*(1/$scaleY)); $nh = round($ah*(1/$scaleY)); } $new_image = imagecreatetruecolor($nw,$nh); imagefill($new_image,0,0,imagecolorallocatealpha($new_image,255,255,255,127)); if($ext=='jpg'||$ext=='jpeg') { $src_image = imagecreatefromjpeg($file); } else if($ext=='gif') { $src_image = imagecreatefromgif($file); } else if($ext=='png') { $src_image = imagecreatefrompng($file); } imagecopyresampled($new_image,$src_image,0,0,0,0,$nw,$nh,$aw,$ah); if($ext=='jpg'||$ext=='jpeg') { imagejpeg($new_image,$file,100); } else if($ext=='gif') { imagegif($new_image,$file); } else if($ext=='png') { imagepng($new_image,$file,9); } imagedestroy($src_image); imagedestroy($new_image); } I have a form with two upload fields, 'face_pic' and 'body_pic', and I want to upload these two to the server and resize them before storing. Any ideas?

    Read the article

  • Javascript can't find element by id?

    - by Bluemagica
    <html> <head> <title>Test javascript</title> <script type="text/javascript"> var e = document.getElementById("db_info"); e.innerHTML='Found you'; </script> </head> <body> <div id="content"> <div id="tables"> </div> <div id="db_info"> </div> </div> </body> </html> If I use alert(e); it turns up null.... and obviously I don't get any "found you" on screen. What am I doing wrong?

    Read the article

  • How do I make a multiple file upload?

    - by Bluemagica
    I am trying to make a multiple image uploader. The file upload fields are being added in the form dynamically using jquery. I tried making an array of the fields since I don't want to have a hidden field. so my generated upload fields look like <input type="file" id="img0" name="img[]"/> <input type="file" id="img1" name="img[]"/> <input type="file" id="img2" name="img[]"/> ..... .. And on the php side I did something like if(isset($_FILES['img'])) { foreach($_FILES['img'] as $k=>$v) { if($v!="") { uploadImage($k,0,0,0,"content/gallery/"); } } } Now I know I am way too wrong, since in that code I am looping through the 'img' file's properties instead of all images....but I have no idea how to fix this. PS: uploadImage is a function I wrote which expects the file input field's name as the first parameter.

    Read the article

1