Jump to content

miligraf

Members
  • Posts

    74
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

miligraf's Achievements

Member

Member (2/5)

0

Reputation

  1. Yeah, i knew i forgot something lol. After the image is uploaded and it is resized and a thumbnail created, it is supposed to show the images but i only get a blank page and when i look at the code i have this: <img src="http://www.miligraf.com/jaimev/img_anuncios/69063"> It only posts the random number but the name should be a random number and the original name of the image, also the file type (jpg) is missing.
  2. It was working fine until i added the image crop code... <? if($_POST['ponerfotos']){ $cuan = $_POST['cuan']; for ($i=1; $i<=$cuan; $i++){ $cantfoto=$_POST['cantfoto']; for ($j=1; $j<=$cantfoto; $j++){ $file_tmp_name = $HTTP_POST_FILES['imagen_'.$i.'_'.$j]['tmp_name']; $file_name = $HTTP_POST_FILES['imagen_'.$i.'_'.$j]['name']; $valid = array (".jpg",".jpeg"); $random_digit=rand(00000,99999); $new_file_name=$random_digit.$file_name; $path= "/home/content/m/i/l/miligraf/html/jaimev/img_anuncios/".$new_file_name; $img= "http://www.miligraf.com/jaimev/img_anuncios/".$new_file_name; $pathcrop= "/home/content/m/i/l/miligraf/html/jaimev/img_anuncios/crop/".$new_file_name; $imgcrop= "http://www.miligraf.com/jaimev/img_anuncios/crop/".$new_file_name; if(copy($file_tmp_name, $path)){ $type = strtolower(strstr($file_name, '.')); if (!in_array($type, $valid)){ echo 'La imágen #'.$j.' del anuncio #'.$i.'no es un archivo .jpg ó .jpeg, porfavor vuelva a subir dicha imágen.'; unlink($path); }else{ list($width, $height)=getimagesize($path); if ($width>550){ $nuevowidth=550; $nuevoheight=($height*550)/$width; $resized_img = imagecreatetruecolor($nuevowidth,$nuevoheight); $new_img = imagecreatefromjpeg($file_tmp_name); imagecopyresampled($resized_img, $new_img, 0, 0, 0, 0, $nuevowidth, $nuevoheight, $width, $height); imagejpeg($resized_img,$path); imagedestroy($resized_img); imagedestroy($new_img); } $cropwidth = 100; $cropheight = 75; $newwidth = $width / 2; $newheight = $height / 2; $cropLeft = ($newwidth/2) - ($cropwidth/2); $cropHeight = ($newheight/2) - ($cropheight/2); $canvas = imagecreatetruecolor($cropwidth,$cropheight); $piece = imagecreatefromjpeg($file_tmp_name); imagecopyresized($canvas, $piece, 0,0, $cropLeft, $cropHeight, $cropwidth, $cropheight, $newwidth, $newheight); imagejpeg($canvas,$pathcrop,90); imagedestroy($canvas); imagedestroy($piece); } } } } ?> <img src="<? echo $img; ?>" ><br/><br/> <img src="<? echo $imgcrop; ?>" > <? }else{ ?> <div class="pasos"><span>Paso 1</span> > <span>Paso 2</span> > Paso 3<br/> Subir imágenes de anuncio(s).</div> <br/> <? include('conbd.php'); $query="SELECT cantfoto FROM stats WHERE ip='$user'"; extract($row = mysql_fetch_array(mysql_query($query))) or die ("Error: $query. " . mysql_error()); ?> Tu cuenta solo te permite subir <? echo $cantfoto; ?> fotos por anuncio y las imágenes deben ser .jpg ó .jpeg <br/><br/> <div align="left"> <form action="" method="post" enctype="multipart/form-data"> <? $cuan = $_POST['cuan']; for ($i=1; $i<=$cuan; $i++){ ?> <div class="mayuscula"><strong>Anuncio #<? echo $i; ?></strong></div><br/> <? for ($j=1; $j<=$cantfoto; $j++){ ?> Imágen #<? echo $j; ?> <input name="imagen_<? echo $i;?>_<? echo $j; ?>" type="file" class="campo" size="85%"><br/> <? }?> <br/> <? } ?> <input type="hidden" name="cuan" value="<? echo $cuan; ?>"> <input type="hidden" name="cantfoto" value="<? echo $cantfoto; ?>"> <input name="ponerfotos" type="Submit" class="campo" value="Agregar"> <input type="reset" class="campo" value="Limpiar"></form> </div> <? } ?> What could it have wrong?! Thanks for your help.
  3. Also i am getting a Resource id #4 error, what is this?
  4. Hello, what i am trying to do is to upload an image and check if it exceeds a width of 550 pixels, if it does then it should resize it but i get these two warnings: Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/content/m/i/l/miligraf/html/jaimev/pag/imagen_test.php on line 30 Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/content/m/i/l/miligraf/html/jaimev/pag/imagen_test.php on line 33 Here is the code: <? if($_POST['ponerfotos']){ $cuan = $_POST['cuan']; for ($i=1; $i<=$cuan; $i++){ $cantfoto=$_POST['cantfoto']; for ($j=1; $j<=$cantfoto; $j++){ $file_name = $HTTP_POST_FILES['imagen_'.$i.'_'.$j]['name']; $valid = array (".jpg",".jpeg"); $random_digit=rand(00000,99999); $new_file_name=$random_digit.$file_name; $path= "/home/content/m/i/l/miligraf/html/jaimev/img_anuncios/".$new_file_name; $img= "http://www.miligraf.com/jaimev/img_anuncios/".$new_file_name; if(copy($HTTP_POST_FILES['imagen_'.$i.'_'.$j]['tmp_name'], $path)){ $type = strtolower(strstr($file_name, '.')); if (!in_array($type, $valid)){ echo 'La imágen #'.$j.' del anuncio #'.$i.'no es un archivo .JPG ó .JPEG, porfavor vuelva a subir dicha imágen.'; unlink($path); }else{ list($width, $height)=getimagesize($path); if ($width>550){ $new_img = imagecreatefromjpeg($tmp_name); $diferencia=$width-550; $nuevowidth=550; $nuevoheight=$height-$diferencia; if (function_exists(imagecreatetruecolor)){ $resized_img = imagecreatetruecolor($nuevowidth,$nuevoheight); }else{ die("Error: Please make sure you have GD library ver 2+"); } imagecopyresampled($resized_img, $new_img, 0, 0, 0, 0, $nuevowidth, $nuevoheight, $width, $height); imagejpeg($resized_img,$path); imagedestroy($resized_img); imagedestroy($new_img); } echo $resized_img; ?> <img src="<? echo $resized_img; ?>" > <? } } } } }else{ ?> <div class="pasos"><span>Paso 1</span> > <span>Paso 2</span> > Paso 3<br/> Subir imágenes de anuncio(s).</div> <br/> <? include('../conbd.php'); $query="SELECT cantfoto FROM stats WHERE ip='miligraf'"; extract($row = mysql_fetch_array(mysql_query($query))) or die ("Error: $query. " . mysql_error()); ?> Tu cuenta solo te permite subir <? echo $cantfoto; ?> fotos por anuncio y las imágenes deben ser .jpg ó .jpeg <br/><br/> <div align="left"> <form action="" method="post" enctype="multipart/form-data"> <? $cuan = 1; for ($i=1; $i<=$cuan; $i++){ ?> <div class="mayuscula"><strong>Anuncio #<? echo $i; ?></strong></div><br/> <? for ($j=1; $j<=$cantfoto; $j++){ ?> Imágen #<? echo $j; ?> <input name="imagen_<? echo $i;?>_<? echo $j; ?>" type="file" class="campo" size="85%"><br/> <? }?> <br/> <? } ?> <input type="hidden" name="cuan" value="<? echo $cuan; ?>"> <input type="hidden" name="cantfoto" value="<? echo $cantfoto; ?>"> <input name="ponerfotos" type="Submit" class="campo" value="Agregar"> <input type="reset" class="campo" value="Limpiar"></form> </div> <? } ?> Thanks for your help!
  5. Is it posible to get a optgroup label in a variable with php? Example: <form action="" method="post" enctype="multipart/form-data"> <select name="color"> <optgroup label="Light colors"> <option value="Red">Red</option> <option value="Blue">Blue</option> <option value="Green">Green</option> <option value="Yellow">Yellow</option> <optgroup> </form> That way i can have the variables (example) Category: Light Colors (optgroup) and Color: Red. Thanks!
  6. I got some info (news system) in a SQL database but after some days it deletes by itself it happened to me once but i thought i didnt remembered that i deleted it but today it happened again...it deleted by itself! lol I have other tables in the same database so its a table problem... How can i fix this? Did i miss something at the table configuration? Thanks!
  7. The session is deleted if i only reload the page...even if its actually logged in.
  8. I get the same problem in all, after i try to access a new page with de session. what should i have "on" or "off" at my php.ini file ??? I dont know if i shouldnt post this but here it goes, the php.ini file: register_globals = off allow_url_fopen = off expose_php = Off max_input_time = 60 variables_order = "EGPCS" extension_dir = ./ upload_tmp_dir = /tmp precision = 12 SMTP = relay-hosting.secureserver.net url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset=" [Zend] zend_extension=/usr/local/zo/ZendExtensionManager.so zend_extension=/usr/local/zo/4_3/ZendOptimizer.so
  9. Still the same problem, with or without buffers.
  10. I get: Array ( [user] => miligraf ) when i login but when i'm not or when i click the "edit" link if goes: Array (). I know what it means but where or how do i loose the session?
  11. Here is the problem: I made a user login system, after they login (this works fine) a menu shows up so they can edit their account info, when i click the link and the new page loads, it deletes the session so i get the username and password fields again. session_start(); is at the index, so it is in all the pages. This is the code for the login: <? if(!isset($_SESSION['user'])){ if($_POST['login']){ ob_start(); include('database.php'); $sql="SELECT * FROM users WHERE name='$name' and pass='$pass'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ $_SESSION['user']=$name; ?> You are now logged in! <? }else{ ?> Try again. <? } ob_end_flush(); mysql_close($connection); }else{ ?> <form action="" method="post" enctype="multipart/form-data"> Name:<br/><input name="name" id="name" size="27%" type="text"><br/><br/> Password:<br/><input name="pass" id="pass" size="27%" type="password"><br/><br/> <input name="login" type="Submit" value="Login"> <input type="reset" value="Clear"></form> <? } }else{?> <strong>My account</strong><br/> <a href="?page=account&action=edit" class="enlace">Edit account</a><br/> <a href="<? session_destroy(); ?>">Logout</a> <? } ?> Then, there is the account.php file which has the IF and ELSEIF for every "action" setting. Thanks.
  12. ok i was not so specific, sorry Heres an example with a table: id-----------name-------------thing----------color 01----------Jones-------------car------------red 02----------Al-----------------house---------blue 03----------Cher--------------bottle----------yellow 04----------Santana-----------cat------------red 05----------Maggie------------bicycle---------green 06----------Homer-------------plane-----------yellow How can i get the info in the "color" field like this: red, blue, yellow, green. (with the colors not being repeated) Instead of getting each "color" of each "id": red, blue, yellow, red, green, yellow. I hope you understand me, thanks.
  13. I have a field that has only 4 different information, lets say that the field's name is "color" and it has 4 different information that are: red, blue, green and yellow. How can i get those 4 or more colors out of the field with PHP? Thanks!
×
×
  • 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.