Jump to content

fireice87

Members
  • Posts

    44
  • Joined

  • Last visited

    Never

Everything posted by fireice87

  1. ok i was a little confused by that but i think im with you now im not very good with php so before i tackle actually coding it and the unlimited syntax errors that i will create i knocked up some psuedo code to make sure im understanding get image size (200 x 150) if width > height { target_width = 110 target_width/width = 0.55 ratio = 0.55 width * ratio = new_width height * ratio = new_height } else { target_height = 90 target_height/height = 0.6 ratio = 0.6 width * ratio = new_width height * ratio = new_height create(newwidth,newheight) Im pretty sure this is the idea ?
  2. iv been resizing images for storage on my site with a simple function but its been bugging me that portraight pictures come out so much bigger than landscape. i took a screen shot and shoved it into fireworks to check size, the max height on portraight pictures is the same as the max width on landscape when i realised its because of the screen resolution. heres my simple resize algorithym // get size of image list($width,$height)=getimagesize($uploadedfile); // set resize er size $newwidth=110; $newheight=($height/$width)*110; $tmp=imagecreatetruecolor($newwidth,$newheight); what would you do to compensat for this? 110 width is the perfect size so i dont want to change this but 110 is to tall but capping the height down would make it thinner too (unless loosing the ratio)making it to small......... obvously the only choice is a compremise if i wanted to keep my resize code as it is. so landscape style images have width set to 110 how would i make portraight images say be 90 pixels high and keep the ratio.
  3. ;D ;D Thank you again, youv helped me out alot with this and its greatly appreciated thank you!
  4. Thank you that did help and put me very close to what i want but that script displays like this http://thewu.site23.co.uk/browseallprofiles4.php i have alterd the code slightly id got it too display how i want to in firefox but annoyling in Internet explorer 6 it looks completly diffrent http://thewu.site23.co.uk/browseallprofiles3.php firefox explorer heres the code as it is now <?php echo "<table>"; // display the users in table $c = 0; while($row = mysql_fetch_array($result)) { $user2 = $row['user']; if($c%5 == 0) echo "<tr height=\"150px\">"; // If the counter has ticked 6 times, start a new row. echo "<td><a href='ViewProfile.php?view=$user2'>$user2</a>"; echo "<img src='DisplayPic_Tiny/".$row['user'].".jpg'/></td>"; // use the varaible row to display image DisplayPic_Tiny/user if($c%5 == 4) echo "</tr>"; // If we're drawing the 6th pic, end this row. $c++; } if($c%5 != 4) echo "</tr>"; // If there isn't a number of pics divisible by 6, end the row echo "</table>"; // end the table ?> Iv tried alot of diffrent ways to get this to display right but cant get it right i thought the issue between the browsers may be due to the row height but that didnt work as both the link and the pic are in the same cell is it that internet explorer just orders things horizontally in this situation firefox orders things vertically once again any help one be great thanks ???
  5. Intro Right iv got this website, with this webpage http://thewu.site23.co.uk/browseallprofiles3.php as you can see the data (pictures and usernames) are shown in a vertical line right down the page. what i want is to show them in a grid say 6x6 for example. My issue is well i cant figure out how to do it ill show you the code then explain why im stumped. Code <?php $conn = @mysql_connect( "blaaah", "nlaaah", "andblaaah") or die ("could not connect to mysql"); #Connect to mysql $rs = @mysql_select_db( "site23_thewu", $conn ) or die ("Could not select database"); #select database $sql = "Select `user` FROM profile_quickfacts"; //pull the users from the table $result= @mysql_query($sql, $conn ) or die(" Could not add style facts"); echo "<table>"; // display the users in table while($row = mysql_fetch_array($result)) { $user2 = $row['user']; echo "<tr>"; echo "<td>" ?><a href=" <?php echo "ViewProfile.php?view=$user2"?>"> <?php echo $user2 ?> </a><?php "</td>"; echo "</tr>"; echo "<td>" ?> <img src="DisplayPic_Tiny/<?php echo $row['user']?>.jpg"/> <?php "</td>"; // use the varaible row to display image DisplayPic_Tiny/user } ?> code explained Right so for each while loop the user is put into the variable $user2 this variable is then used to create the link to the users profile and to diaply there image, and its all displayed in a table. Problem i need about a 5x6 table not just a vertical line but i cant simply make the table in the while loop be 6x6 as it will keep displaying the same user. possible solution? I thought about maybe adding a (while $count < 6)style condition, so the loop would go around 6 times creating a vertical row of 6 then stop. and then do this again to the right of this table whitch would create a seconded vertical row of 6 so itd be 6x2, and repeating this till i had 6x5. The problem with this is i dont know how to start the seconed loop 6 rows down as too not display the same users. I hop this makes sense and im not over complicating the matter iv be at this for a while and my brains is a bit frazzeld so hopefully im making sense! thanks for any help
  6. Thanks alot that works perfectly iv been trying many what know seem slighlty iraational methods to get that to work all day! thats very useful to know i think ill be looking into that as tbh i knew nothing of it ??? cheers!
  7. Right iv got this page http://www.thewu.site23.co.uk/browseallprofiles.php whitch works like this $sql = "Select `user` FROM profile_quickfacts"; //pull the users from the table $result= @mysql_query($sql, $conn ) or die(" Could not add style facts"); echo "<table>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" ?> <a href="ViewProfile.php"><?php echo $row['user'] ?></a> <?php "</td>"; //use the variable row to show username $view = $row['user']; echo "</tr>"; echo "<td>" ?> <img src="DisplayPic_Tiny/<?php echo $row['user']?>.jpg"/> <?php "</td>"; // use the varaible row to display image DisplayPic_Tiny/user echo "</tr>"; } echo "</table>"; clicking the user name acts as a link to the page ViewProfile.php but what i need to do is pass to the ViewProfile.php page the $row['user'] variable as the next page works like this $sql = "Select `user`,`displayname`,`category`,`sex`,`orientation`,`status`,`location`,`highSchool`,`occupation`,`day`,`month`,`year` FROM profile_quickfacts WHERE user= '$row' "; --------------------display code i cant figure out how to get the variable across i cant use a cookie as it needs to be in a middle of the page as you can see from the link above im thinking i need to use a form but cant quite figure out how to do it iv got to this http://www.thewu.site23.co.uk/browseallprofiles2.php while($row = mysql_fetch_array($result)) { ?> <form action="StoreLists.php" method="post"> <?php echo "<tr>"; echo "<td>" ?> <a href="ViewProfile.php"><?php echo $row['user'] ?></a> <?php "</td>"; //use the variable row to show username $view = $row['user']; echo "</tr>"; echo "<td>" ?> <img src="DisplayPic_Tiny/<?php echo $row['user']?>.jpg"/> <?php "</td>"; // use the varaible row to display image DisplayPic_Tiny/user echo "</tr>"; echo "<td>" ?><input type="submit" value="view profile" name="view" /><?php "</td>"; ?> </form> <?php } echo "</table>"; ?> i think im almost there but cant figure out how to get the form to actual pass the variable i want it too the $row['user'] varibale so i can use it to pull the right user from the database on the viewprofile page by using WHERE user = $variable thanks for anyhelp
  8. Hey iv got a script that works out the users age from there dob $ageTime = mktime(0, 0, 0, 9, 8, 1987); // Get the person's birthday timestamp $t = time(); // Store current time for consistency $age = ($ageTime < 0) ? ( $t + ($ageTime * -1) ) : $t - $ageTime; $year = 60 * 60 * 24 * 365; $ageYears = $age / $year; echo 'You are ' . floor($ageYears) . ' years old.'; Im trying to expand this so that i can pull the DOB from the database and use variables to insert the DOB into the mktime( ). below is the code i have written to pull the dob from the database and add it too the calculation for the users age problem im having is that the age doesnt make it to the database. the error i get is when it should be inserted into the database iv used the code to get it into the database multiple times in diffrent scripts so i know thats fine so im thinking the error is something to do with the way im tring to use the variables in the calculation. any help would be great as i cant work out the issue here... thanks $conn = @mysql_connect( "localhost", "username", "password") or die ("could not connect to mysql"); #Connect to mysql $rs = @mysql_select_db( "site23_thewu", $conn ) or die ("Could not select database"); #select database $sql0 = "DELETE 'age' FROM profile_quickfacts WHERE user= '$user'"; $empty= $run= @mysql_query($sql0, $conn ) or die(" Could not add quick facts"); $sql = "Select `day`,`month`,`year` FROM profile_quickfacts WHERE user= '$user' "; $result= @mysql_query($sql, $conn ) or die(" Could not select data"); while($row = mysql_fetch_row($result)) { $Day = $row[1]; $Month = $row[2]; $Year = $row[3]; } $ageTime = mktime(0, 0, 0, ($Day), ($Month), ($Year)); // Get the person's birthday timestamp $t = time(); // Store current time for consistency $age = ($ageTime < 0) ? ( $t + ($ageTime * -1) ) : $t - $ageTime; $year = 60 * 60 * 24 * 365; $ageYears = $age / $year; // echo 'You are ' . floor($ageYears) . ' years old.'; $sql3 = "INSERT INTO profile_quickfacts(`age`) VALUES (\"$ageYears\");"; $run= @mysql_query($sql3, $conn ) or die(" Could not add quick facts");
  9. i may be wrong but there seems to be no audio alternative with that script? this would leave visualy imparied users stranded witch goes against web standards
  10. Hey Im looking into adding captcha to a registration form iv just used the sample from the captcha.net website to try it out and figure out how it works. Iv directly copied and pasted the code but its not quite working. Iv made no alterations to the code but keep getting the message "'Every CAPTCHA can only be used once. The current CAPTCHA has already been used. Try again.';" as theres no forum on the captcha website im finding it hard to find what is causing this. On the website (http://captchas.net/sample/php/) there is code for an input form and a cheack form along with the captcha function page below are copies of these I figure as iv made no alterations this is probably some thing easy iv done wrong or a common mistake here is the section of code that triggers the message: <?php // Check the random string to be valid and return an error message // otherwise. if (!$captchas->validate ($random_string)) { echo 'Every CAPTCHA can only be used once. The current CAPTCHA has already been used. Try again.'; } // Check, that the right CAPTCHA password has been entered and // return an error message otherwise. elseif (!$captchas->verify ($password)) { echo 'You entered the wrong password. Aren\'t you human? Please use back button and reload.'; } // Return a success message else { echo 'Your message was verified to be entered by a human and is "' . $message . '"'; } ?> The function: <?php // // PHP module for easy utilization of the free captchas.net CAPTCHA service // // For documentation look at http://captchas.net/sample/php/ // // Written by // Sebastian Wilhelmi <[email protected]> and // Felix Holderied <[email protected]> // This file is in the public domain. // // ChangeLog: // // 2006-08-16: New optional features integrated // // 2006-03-01: Only delete the random string from the repository in // case of a successful verification. // // 2006-02-14: Add new image() method returning an HTML/JavaScript // snippet providing a fault tolerant service. // // 2005-06-02: Initial version. // class CaptchasDotNet { function CaptchasDotNet ($client, $secret, $random_repository = '/strings/captchasnet-random-strings', $cleanup_time = 3600, $alphabet = 'abcdefghijklmnopqrstuvwxyz', $letters = 6, $width = 240, $height = 80 ) { $this->__client = $client; $this->__secret = $secret; $this->__random_repository = $random_repository; $this->__cleanup_time = $cleanup_time; $this->__time_stamp_file = $random_repository . '/__time_stamp__'; $this->__alphabet = $alphabet; $this->__letters = $letters; $this->__width = $width; $this->__height = $height; } function __random_string () { // The random string shall consist of small letters, big letters // and digits. $letters = "abcdefghijklmnopqrstuvwxyz"; $letters .= strtoupper ($letters) + "0123456789"; // The random starts out empty, then 40 random possible characters // are appended. $random_string = ''; for ($i = 0; $i < 40; $i++) { $random_string .= $letters{rand (0, strlen ($letters) - 1)}; } // Return the random string. return $random_string; } // Create a new random string and register it. function random () { // If the repository directory is does not yet exist, create it. if (!is_dir ($this->__random_repository)) { mkdir ($this->__random_repository); } // If the time stamp file does not yet exist, create it. if (!is_file ($this->__time_stamp_file)) { touch ($this->__time_stamp_file); } // Get the current time. $now = time (); // Determine the time, before which to remove random strings. $cleanup_time = $now - $this->__cleanup_time; // If the last cleanup is older than specified, cleanup the // directory. if (filemtime ($this->__time_stamp_file) < $cleanup_time) { $handle = opendir ($this->__random_repository); while (true) { $filename = readdir ($handle); if (!$filename) { break; } if ($filename != '.' && $filename != '..') { $filename = $this->__random_repository . '/' . $filename; if (filemtime ($filename) < $cleanup_time) { unlink ($filename); } } } closedir ($handle); touch ($this->__time_stamp_file); } // loop until a valid random string has been found and registered, // but at most 20 times. If no valid random has been found during // that time, there is something really wrong. Also show the error // in the last run. for ($remaining = 20; $remaining > 0; $remaining--) { // generate a new random string. $random = $this->__random_string (); // open a file with the corresponding name in the repository // directory in such a way, that the creation fails, when the // file already exists. That should be near to impossible with // good seeding of the random number generator, but it's better // to play safe. If this is the last run, show the possible // error message. $filename = $this->__random_repository . '/' . $random; if ($remaining == 1) { $file = fopen ($filename, 'x'); } else { $file = @fopen ($filename, 'x'); } if ($file) { fclose ($file); break; } // if the file already existed, rerun the loop to try the next // string. } // return the successfully registered random string. $this->__random = $random; return $random; } // // Generates image-URL Parameters are only atached if different from default // function image_url ($random = False, $base = 'http://image.captchas.net/') { if (!$random) { $random = $this->__random; } $image_url = $base; $image_url .= '?client=' . $this->__client; $image_url .= '&random=' . $random; if ($this->__alphabet!='abcdefghijklmnopqrstuvwxyz') {$image_url .= '&alphabet=' . $this->__alphabet;}; if ($this->__letters!=6) {$image_url .= '&letters=' . $this->__letters;}; if ($this->__width!=240) {$image_url .= '&width=' . $this->__width;}; if ($this->__height!=80) {$image_url .= '&height=' . $this->__height;}; return $image_url; } // // Same as image_url but without width and height // function audio_url ($random = False, $base = 'http://audio.captchas.net/') { if (!$random) { $random = $this->__random; } $audio_url = $base; $audio_url .= '?client=' . $this->__client; $audio_url .= '&random=' . $random; if ($this->__alphabet!='abcdefghijklmnopqrstuvwxyz') {$audio_url .= '&alphabet=' . $this->__alphabet;}; if ($this->__letters!=6) {$audio_url .= '&letters=' . $this->__letters;}; return $audio_url; } // // Generates complete html-sample with javascript to reload image from // backup server // function image ($random = False, $id = 'captchas.net') { $image = <<<EOT <a href="http://captchas.net"><img style="border: none; vertical-align: bottom" id="@ID@" src="@URL@" width="@WIDTH@" height="@HEIGHT@" alt="The Captcha image" /></a> <script type="text/javascript"> <!-- function captchas_image_error (image) { if (!image.timeout) return true; image.src = image.src.replace (/^http:\/\/image\.captchas\.net/, 'http://image.backup.captchas.net'); return captchas_image_loaded (image); } function captchas_image_loaded (image) { if (!image.timeout) return true; window.clearTimeout (image.timeout); image.timeout = false; return true; } var image = document.getElementById ('@ID@'); image.onerror = function() {return captchas_image_error (image);}; image.onload = function() {return captchas_image_loaded (image);}; image.timeout = window.setTimeout( "captchas_image_error (document.getElementById ('@ID@'))", 10000); image.src = image.src; //--> </script> EOT; $image = str_replace ('@HEIGHT@', $this->__height, $image); $image = str_replace ('@WIDTH@', $this->__width, $image); $image = str_replace ('@ID@', $id, $image); $image = str_replace ('@URL@', $this->image_url (), $image); return $image; } function validate ($random) { $this->__random = $random; $file_name = $this->__random_repository . '/' . $random; // Find out, whether the file exists $result = is_file ($file_name); // if the file exists, remember it. if ($result){ $this->__random_file = $file_name; } // the random string was valid, if and only if the corresponding // file existed. return $result; } function verify ($input, $random = False) { if (!$random) { $random = $this->__random; } $password_letters = $this->__alphabet; $password_length = $this->__letters; // If the user input has the wrong lenght, it can't be correct. if (strlen ($input) != $password_length) { return False; } // Calculate the MD5 digest of the concatenation of secret key and // random string. The digest is a hex string. $encryption_base = $this->__secret . $random; // This extension is needed for secure use of optional parameters // In case of standard use we do not append the values, to be // compatible to existing implementations if(($password_letters != 'abcdefghijklmnopqrstuvwxyz') || ($password_length != '6')) { $encryption_base = $encryption_base . ':' . $password_letters . ':' . $password_length; } $digest = md5 ($encryption_base); // Check the password according to the rules from the first // positions of the digest. for ($pos = 0; $pos < $password_length; $pos++) { $letter_num = hexdec (substr ($digest, 2 * $pos, 2)) % strlen ($password_letters); // If the letter at the current position is wrong, the user // input isn't correct. if ($input[$pos] != $password_letters[$letter_num]) { return False; } } // if the file exists, remove it. if ($this->__random_file) { unlink ($this->__random_file); unset ($this->__random_file); } // The user input was correct. return True; } } ?> Input page: <?php require 'CaptchasDotNet.php'; // Required Parameters // Replace the values you receive upon registration at http://captchas.net. // // client: 'demo' // // secret: 'secret' // // Optional Parameters and defaults // // repository_prefix: '/tmp/captchasnet-random-strings' path to repository // ATTENTION SAFE-MODE, YOU HAVE TO CHOOSE SOMETHING LIKE // '/writable/path/captchasnet-random-strings' // // cleanup_time: '3600' (means max 1 hour between query and check) // // alphabet: 'abcdefghijklmnopqrstuvwxyz' (Used characters in captcha) // We recommend alphabet without ijl: 'abcdefghkmnopqrstuvwxyz' // // letters: '6' (Number of characters in captcha) // // width: '240' (image width) // // height: '80' (image height) // // Usage // $captchas = new CaptchasDotNet (<client>, <secret>, // <repository_prefix>, <cleanup_time>, // <alphabet>,<letters>, // <height>,<width>); // // Don't forget same settings in check.asp // Construct the captchas object. $captchas = new CaptchasDotNet ('demo', 'secret', '/tmp/captchasnet-random-strings','3600', 'abcdefghkmnopqrstuvwxyz','6', '240','80'); ?> <html> <head> <title>Sample PHP CAPTCHA Query</title> </head> <h1>Sample PHP CAPTCHA Query</h1> <form method="get" action="check.php"> <table> <tr> <td> <input type="hidden" name="random" value="<?= $captchas->random () ?>" /> Your message:</td><td><input name="message" size="60" /> </td> </tr> <tr> <td> The CAPTCHA password: </td> <td> <input name="password" size="6" /> </td> </tr> <tr> <td> </td> <td> <?= $captchas->image () ?> <br> <a href="<?= $captchas->audio_url () ?>">Phonetic spelling (mp3)</a> </td> </tr> <tr> <td> </td> <td> <input type="submit" value="Submit" /> </td> </tr> </table> </form> </html> Check page: [code]<?php require 'CaptchasDotNet.php'; // See query.php for documentation $captchas = new CaptchasDotNet ('demo', 'secret', '/tmp/captchasnet-random-strings','3600', 'abcdefghkmnopqrstuvwxyz','6', '240','80'); // Read the form values $message = $_REQUEST['message']; $password = $_REQUEST['password']; $random_string = $_REQUEST['random']; ?> <html> <head> <title>Sample PHP CAPTCHA Query</title> </head> <h1>Sample PHP CAPTCHA Query</h1> <?php // Check the random string to be valid and return an error message // otherwise. if (!$captchas->validate ($random_string)) { echo 'Every CAPTCHA can only be used once. The current CAPTCHA has already been used. Try again.'; } // Check, that the right CAPTCHA password has been entered and // return an error message otherwise. elseif (!$captchas->verify ($password)) { echo 'You entered the wrong password. Aren\'t you human? Please use back button and reload.'; } // Return a success message else { echo 'Your message was verified to be entered by a human and is "' . $message . '"'; } ?> </html> [/code] Thanks for looking and for any help EDIT: well i mean i did make one alteration i changed the user name and password from demo and secret to my actual details
  11. Hey thanks alot i did need to just add echo and it all works thanks, yeah the css styling rules on in the head of a php document thanks for your help
  12. Hey iv got a script that can add colour codes to a data base and a script that pulls them out again This code works fine it collects the data from the table and puts it into variables $conn = @mysql_connect( "localhost", "user", "pass") or die ("could not connect to mysql"); #Connect to mysql $rs = @mysql_select_db( "db", $conn ) or die ("Could not select database"); #select database $sql = "Select `Backgroundcolour`,`Backgroundimage`,`Bordercolour`,`Borderthickness`,`Headingtextcolour`,`Headingtextsize`,`Maintextcolour`,`Maintextsize` FROM style_$user where id=1"; $result= @mysql_query($sql, $conn ) or die(" Could not add style facts"); while($row = mysql_fetch_row($result)) { $Backgroundcolour = $row[0]; $Backgroundimage = $row[1]; $Bordercolour = $row[2]; $Borderthickness = $row[3]; $Headingtextcolour = $row[4]; $Headingtextsize = $row[5]; $Maintextcolour = $row[6]; $Maintextsize = $row[7]; } But this bit of code doesnt work (in css) #Profile { height: 700px; width: 920px; background-color: <?php $Backgroundcolour ?> ; } what happens is the page display correctly(no errors) but with out any attention to the colours the variables are holding is there a way to do what im trying or am i on the wrong tracks with this? thanks
  13. having the button appear when text is being typed isnt possible with php, as it has to call to the server. where as java script/ajax could do this. i know next to nothing of java script so thats all i can say im afraid
  14. lol yeah think i was on a completly diffrent track with this one ignore me
  15. Hey im new to php myself but i can help you with this a bit. For php to be able to display an image you need to set the header to the file type for example....header("Content-Type: image/jpeg"); Im not sure if this allows you to display multiple images on a page it deffenitly wont if the images are of diffrent file types. If you need to display multiple images you may need to write the image display code on a seperate php page and link to that page as the image source. are you getting any erros? or are the images just not displaying? hope that helps a bit
  16. ok cheers will move it across and close this
  17. 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 Grin
  18. 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
  19. Hey im just starting to learn php and mysql im using xampp as my server iv established a connection between php and mysql im trying to create a dataasbe by using php. but i keep getting this error File not found Firefox can't find the file at /C:/xampp/htdocs/<?php echo( $_SERVER['PHP_SELF'] ); ?>. iv taken the code with only the slightest alterations (taken out the username and password) from a tutriol book the problem is the book has plenty of code samples but very little explanation. The code is below: <?php $conn = @mysql_connect("localhost", "root", "") or die( "Sorry - could not connect to MYSQL" ); $rsl = @mysql_create_db( $_REQUEST['db'] ); $rs2 = @mysql_list_dbs( $conn ); for ( $row = o; $row < mysql_num_rows( $rs2 ); $row++ ) { $list .= mysql_tablename( $rs2, $row) . " | "; ?> <html><head><title>Create a database</title></head> <body> <form action = "<?php echo( $_SERVER['PHP_SELF'] ); ?>" method="post">Current database: <?php echo( $list ); ?> <hr>Name: <input type = "text" name = "db"> <input type = "submit" value = "Create Database"> </form></body></html> I know very little about php and cant see whats wrong with this as the book does not explain any help or links to tutorials would be great 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.