Jump to content

Tiruak

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Tiruak's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well, I did try that, and it doesn't give me any errors. I did print the array, and it give me all the fields, including all the "’����ª��’ ����²��’����º��’������� ’����Y��� ’����Â��†’���Ê��� ����0100 �������" of the blob field. Now I'm starting to think that it could have something to do with the way I stored the image on the database. I will try to reproduce here, so maybe you can point some mistake for me (btw, I did check the table on phpmyadmin, and the blob field have the image there). Here is what I have on my "insert_form" (I will post only what I think is relevant): <form enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> <input type="file" name="photo" id="photo" /> Now on my receiving script, I have the following: if (isset($_FILES['photo'])) { // begin the image handling code $errors = array(); try { if (!array_key_exists('photo', $_FILES)) { throw new Exception('Image not found as upload'); } $image = $_FILES['photo']; // ensure the file was successfully uploaded assertValidUpload($image['error']); if (!is_uploaded_file($image['tmp_name'])) { throw new Exception('File is not an upload.'); } $info = getImageSize($image['tmp_name']); if (!$info) { throw new Exception('File is not an image.'); } } catch (Exception $ex) { $errors[] = $ex->getMessage(); } if (count($errors) == 0) { // no errors, so insert the image $foto = mysql_real_escape_string(file_get_contents($image['tmp_name'])); $mime = mysql_real_escape_string($image['mime']); } } else { $foto = " "; $mime = " "; } then, after processing some other fields, I have: $query = "INSERT INTO table (arb_photo, mime_type) VALUES ('{$foto}', '{$mime}')"; $result = mysql_query($query, $connection); So that's all the info I think is relevant.
  2. Alright, so I'm having a problem that I can't figure out by my self. I'm just testing a way to display an image. It's not really the application, I'm just making tests with the database. So, I have a table with a medium blob field that contain an image (it's a protrait, very small, less then 100kb). I'm just trying to test it, so I did write a showpic.php script to test it. it follows... $user_id = 10; mysql_connect("localhost","user","pass"); mysql_select_db("my_db"); $q = "select * from my_table where id = '$user_id'"; $r = mysql_query($q); $rset = @mysql_fetch_assoc($r); $imagebytes = $rset[arb_photo]; header("Content-type: image/jpeg"); print $imagebytes; So, I was expecting this to just print the image. What I get instead, is just the web address where the script is, as if it was a broken image. The page title shows showpic.php (JPEG Image) and on the place where the image is supposed to be it shows http://localhost/site/showpic.php When I right click on the "http://localhost/site/showpic.php", it's not a text, it's an image, and when I right click it to see the "View image info" option, it gives me the following: Location: http://localhost/agat/members/showpic.php Type: JPEG image Size: 62,91 KB (64.415 bytes) Dimensions: 0px × 0px (scaled to 256px × 19px) I'm pretty sure it's something related to the dimensions (duh), but I'm not sure what it is. Can anyone help, and show how dumb am I? Thanks in advance!
  3. I will give it another shot... I guess I need to stop cheering for Brazil in the world cup and close the door to concentrate.
  4. Can't edit anymore: Here is what I'm trying to do (the code is just an example, of course): <?php require_once("../includes/connection.php"); ?> <?php require_once("../includes/functions.php"); ?> <?php // header('Content-type: image/jpeg'); $sel_arb = get_arbitro_by_id($_GET['arb']); //echo $sel_arb['arb_photo']; ?> <html> <head> <title>The title is this</title> </head> <body> <table width=50%> <tr> <td>Name is <?php echo $sel_arb['arb_nome'];?></td> <td><?php echo $sel_arb['arb_photo'];?></td> </tr> </table> </body> </html> <?php require("../includes/footer.php"); ?>
  5. Hello there, I've tried everything I can possible think of, and don't seem to get this to work. Once again, I'm new to php I have a database where I upload the user picture. I can get my form to upload and store the image on the database together with my user info. So now, when I try to echo the picture on my user profile, it just shows a bunch of invalid characters, probably due to a header problem. Now, maybe I'm missing the point here, but as far as I've learned, I need to call a header at the beginning of my script, before any html is displayed. But, if I do use something like // header('Content-type: image/jpg'); // at the beginning of my page, it actually makes all my page mess up, and still doesn't show the image. I'm contacting the database correctly, selecting the right user, storing all his info into my array, and trying to display the $user['usr_photo'] of my array. I appreciate any help.
  6. Thank's very much! It gives all the info I need thumbs up!
  7. Well, it probably has a more efficient way to do that, but one thing you could do is create a second function that all it does is to call the function beach(). Something like: function call_beach() { beach(); } Then, if your criteria isn't met, you can just call the funcion call_beach()
  8. Hello there, On my site, I try to store a portrait of my members to be displayed together with their profile. So, on my members database, i have a field named picture, that is a MEDIUMBLOB, where I plan to store the picture. So, I created the form where I can browse the picture. Now I have 2 questions: 1) How would I go about, so when people click "Browse" on the form, it just show certain file extensions? (e.g only showing jpg, gif, png) 2) When I click submit on my form, how should I handle the picture to add it to the database on my receiving script? How do I read the picture back to display to the user? Thanks for your help,
  9. Thanks alot Ken, This solves the problem and also teaches me a new function that may be very helpful
  10. Hello ladies and gals I'm very new to php, only a couple months working with it, and am having some difficult to do a couple of things. My question is probably very stupid, and there are probably some obvious answers to it, but I really appreciate if you can help me get to the solution, even if you have to call me "dumb" after you do it After completing a form, an user has a field to insert a date of birth, in a format dd/mm/yyyy (eg 23/06/1980). When I try to add this to the database, in a field that expects a date, it actually just gives me 0000-00-00 as a result. Now, I understand that the sql database is expecting the date to be passed in a different format, so I tried to use the following command on my date: $date="23/06/1980"; // this variable is just for testing purpose, I actually get the date with $_POST $new_date=date('Y-m-d',strtotime($date)); Now if I echo $new_date, it returns me 1980-23-06, because the strtotime() function expects a date in US English format (m/d/Y). So, I assume the answer is probably simple, but I can't get to format the date in the way I need, to be able to add it to the database and store it correctly. Of course, when I read it back and format to the user to read, I will need to reverse the process, but that should be easy to do once someone helps me to format it to add to the database. Thanks for any help, and I'm sorry if this has been asked a thousand times.
×
×
  • 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.