fireice87 Posted April 29, 2007 Share Posted April 29, 2007 Hey iv got a form that lets a user upload an image, the image is then stored in a table called displaypic_$user. I have a profile page for the user that calls on this image using <img src="ProfilePic.php" /> (the php page holds the script for resizing and displaying) This was working fine when i was not tring to alter the images size. Iv now tried to alter the size of the image before displaying and get several error messages on the ProfilePic.php page. Below is the code for the form that upoads the image <?php if ($submit) { $conn = mysql_connect("localhost","user","pass"); mysql_select_db("user"); $sql0 = "DELETE FROM displaypic_$user WHERE id='1'"; $empty= @mysql_query($sql0, $conn ) or die(" Could not delete pic"); $data = addslashes(fread(fopen($form_data, "r"), filesize($form_data))); $id= "1" ; $result=mysql_query("INSERT INTO displaypic_$user (id,description,bin_data,filename,filesize,filetype) ". "VALUES ('$id','$form_description','$data','$form_data_name','$form_data_size','$form_data_type')"); } else { ?> <form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data"> <h5>Upload Picture 1</h5> Description for picture 1 <br> <input type="text" name="form_description" size="40"> <input type="hidden" name="MAX_FILE_SIZE" value="220000"> <br> Choose image to upload for picture 1 (images must not be bigger than 200KB) <br> <input type="file" name="form_data" size="40"> </p> <p><input type="submit" name="submit" value="submit"> </form> <?php } ?> here is the code for ProfilePic.php that is used as the image source <?php $user = $_COOKIE['username']; @mysql_connect("localhost","user","pass"); @mysql_select_db("user"); $query = "select bin_data,filetype from displaypic_$user where id=1"; $result = @mysql_query($query); $image = @mysql_result($result,0,"bin_data"); $type = @mysql_result($result,0,"filetype"); $width = imagesx($image); $height = imagesy($image); $new_width = 150; $new_height = 250; $image_resized = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); header("Content-Type: image/jpeg"); imagejpeg($image_resized); ?> heres the error message profilepic.php shows it seems to be pretty much saying that it cant do it to the file but the file is a jpeg so there is no reason it couldnt any help would be greatly appreciated cheers Warning: imagesx(): supplied argument is not a valid Image resource in /home/site23/public_html/thewu/ProfilePic.php on line 14 Warning: imagesy(): supplied argument is not a valid Image resource in /home/site23/public_html/thewu/ProfilePic.php on line 15 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/site23/public_html/thewu/ProfilePic.php on line 20 Warning: Cannot modify header information - headers already sent by (output started at /home/site23/public_html/thewu/ProfilePic.php:14) in /home/site23/public_html/thewu/ProfilePic.php on line 22 Resource id #3 Quote Link to comment https://forums.phpfreaks.com/topic/49170-solved-image-manipulation-erros-reading-image-from-mysql/ Share on other sites More sharing options...
bubblegum.anarchy Posted April 29, 2007 Share Posted April 29, 2007 The issue here appears to be related with PHP functions rather than mysql specifically - the PHP forum may be more appropriate. Quote Link to comment https://forums.phpfreaks.com/topic/49170-solved-image-manipulation-erros-reading-image-from-mysql/#findComment-240982 Share on other sites More sharing options...
fireice87 Posted April 29, 2007 Author Share Posted April 29, 2007 ok cheers will move it across and close this Quote Link to comment https://forums.phpfreaks.com/topic/49170-solved-image-manipulation-erros-reading-image-from-mysql/#findComment-240991 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.