jacko_162
Members-
Posts
405 -
Joined
-
Last visited
Everything posted by jacko_162
-
yeah i was checking that against the result, hence why i noticed it was wrong. and thank you for the formatting above. looks better..! say if i pull a result of $sum as 1000000 (how can i output this as "1 Million", or 1350000 as "1.35 Million, or 350000 as "0.35 Million" etc..) i looked at number_format() but to no avail.
-
oops, $sum = array_sum($decode); should be: $sum = array_sum($count);
-
i looked at array_sum but i cant seem to get it to add correctly: <?php $file_contents = file_get_contents('http://eve-kill.net/epic/involvedCorp:Skulldogs/mask:16/mailLimit:10'); $decode = json_decode($file_contents, true); $arr = array(); foreach ($decode as $d) { $arr[] = $d['victimName']; } $counts = array_count_values($arr); $sum = array_sum($decode); echo '<pre>'.print_r($counts, 1).'</pre>'; echo "<br><br><br>SUM: "; echo "" . $sum . "\n"; ?> it outputs: Array ( [R4K-8L] => 1 [Calette Zardina] => 1 [sylouis] => 1 [sylia Nimlas] => 1 [Tcpp24] => 2 [Greg Focker Gaylord] => 2 [PMV-G6 VII - Moon 4] => 2 ) SUM: 0 it should give me SUM: 10
-
works great. Thank you, ok and perhaps my last question, the foreach() works and i got my list. on your count code, how can i get it to add up all the amounts? and give a total? for example: Array ( [FSB-ALFA] => 3 [Ministry of War] => 1 [solar Wind] => 1 ) Total: 5
-
The count works great, is it possible to list them using bullet points without the "array ()" and "[]" ?
-
I have the following link; http://eve-kill.net/epic/involvedCorp:Skulldogs/mask:64/mailLimit:5 which pulls an array of victimCorpName and limits the results to 5. how can i get it to list these in a bullet point list and only show the VictimCorpName for example: victimCorpName victimCorpName victimCorpName victimCorpName victimCorpName and if i remove the "limit" is it possible to count the amount of times a certain "victimCorpName" comes up, for example: FSB-Alpha: x7 i tried to use the print_r(&myArray) but to no avail. any help would be appreciated. this is my current code theory: <?php $file_contents = file_get_contents('http://eve-kill.net/epic/involvedCorp:Skulldogs/mask:64/mailLimit:5'); $decode = json_decode($file_contents, true); $encode = json_encode($file_contents); //echo $data[2]->victimCorpName; //echo $data->title; print_r($decode); ?>
-
I want a simple form with 1x Input field; <form> <input name='Volume' type='text' /> <input type='hidden' name='value' value ='850' /> <input type='submit' name='Calculate' /> </form> the input will be a number only, if the user inputs 5 for example: i want it to perform the following maths: 5x$value (5x850) and display the result when the user clicks submit. Also if the user submits a number bigger than 320000 can we output an error message? how would i go about this using simple js ? i have no idea how to code js at the moment.
-
problem is its an already established SMF (FORUM) mod that allows me to add "pages" with php code embedded. the url for the first page is already; all i need is a calculator so a user can input a volume (for example 500) and i need to calculate a reward for the 500 volume base on the following maths: $volume x 850 is there another way i can do this without using a form and the GET method? for example ajax or JS ?
-
I have the following code on the following page; index.php?action=page;id=1 <p><span style="color:#9b6742;font-size:150%;font-weight:bold">Calculate Reward</span> <?php Print "<form action = '$_SERVER[php_SELF]' method = 'GET'> <input type='hidden' name='action' value ='page;id=1'> Total Courier Volume: <input type = 'text' name = 'volume' size='4'> (in m³) <br/> <input type='hidden' name='calc' value ='yes'> <input type = 'submit' name = 'Calculate'/> </form>"; if (($_GET['calc'] == "yes") && ($volume < '320000')) { $volume = $_GET['volume']; $reward = $volume*850; $iskReward = number_format($reward); print "<br><br><span style='color:#9b6742;font-size:150%;font-weight:bold'>Results</span><br><br>"; print "<form>The total Volume for contract is: <font color='#ff9900'><strong>$volume m³</strong></font><br> Total Reward to put on Contract is: <font color='#ff9900'><strong>$iskReward isk</strong></font>"; print " <input type = 'text' name = 'volume' value='$reward' size='8'> <--- Copy and paste reward</form><br><br><br><br>"; } else { //print "<h2>There has been an error</h2>"; } ?> </p> when i submit the form i get the following URL; and what i need is: it looks like its not encoding the special characters ";" and "=" after "action=page" how can i fix this so it outputs what i need. Many thanks.
-
I want an icon on the left of a HTML webpage, when clicked a box slides out with content from the left horizontally, then when the button is clicked again i would like it to slide back to the left hand side of the page. can anyone help me find a script to do this please? its been designed to work this way in photoshop and i cant seem to find anything to code it to behave the same way. Many thanks.
-
Wonder if someone can help me out: i have 3 Tables (kill, Item_dropped, item_price) what i am trying to do is calculate the price of items that have dropped from each individual kill. so the kill_dropped looks like: itd_kll_id itd_itm_id itd_quantity 7926 2476 3 7926 23563 5 7924 31892 1 7924 21640 3 7924 2488 2 then the item_price will be like: id price 2476 300 23563 5000 31892 14500 21640 12000 2488 5650 so i need the query to relate to the following: SELECT all prices where itd_kll_id = 7924 and add them up to give me a total. can anyone help me out? i forgot to mention there is a quantity row to encounter also.
-
i see what you did there indeed much easier way to limit results using the query. marked as solved. thanks guys.
-
so i can specify in the mysql query by using "WHERE" date is between todays date and +7 days?
-
ok where do i need to look in the manual on changing the variable to an int.. i only found something on idate()
-
my database row is stored as "DATE" i didnt think that was a string?
-
i have the below code which i wrote this monring, for some reason when i assign $date to fetch data from my database i just get the echo of "You had an Error" yet if i manually assign $date as the following it works: $date = strtotime("2011-09-20"); i have it set exactly the same in the database cus if i echo $date i get: 2011-09-20 whats going on? date in php is a cruel function to play around with.. here is my code: <?php // Query the DB to fetch all data where member_id matches that set in session $reminder = mysql_query("SELECT * FROM `reminders` WHERE member_id=$_SESSION[sESS_MEMBER_ID]") or die(mysql_error()); //While Loop the results while($fetch = mysql_fetch_array( $reminder )) { // Start date (TODAY!) $s_date = strtotime("now"); // End Date (+7 days from today) $e_date = strtotime("+1 week"); // Fetches Date stamp from "reminderDate" row in DB $date = $fetch['reminderDate']; // Checks if the date is between 2 ranges set above if($date > $s_date && $date < $e_date) //Echo The Results { echo "<div class='notification error png_bg'><a href='#' class='close'><img src='img/cross_grey_small.png' title='Close this notification' alt='close' /></a><div>Custom Error Notification BOX!</div></div>"; } else { echo "You had an Error"; //echo $date; // TEST that date outputs datestamp "2011-09-02" } //END LOOP } ?>
-
struggling to adapt a loop for the <td> to make the grid here =(
-
im just checking out: http://www.phpfreaks.com/tutorial/basic-pagination and following it, so far i understand most of it, is it possible to echo the above tutorial into a grid layout instead of lists? this is my code used from tutorial to provide the page and details; <?php session_start(); include('Includes/auth.php'); require_once('header.php'); // database connection info $conn = @mysql_connect("$host", "$username", "$password"); if (!($conn)) // If no connect, error and exit(). { echo("<p>Unable to connect to the database server.</p>"); exit(); } if (!(@mysql_select_db($database))) // If can't connect to database, error and exit(). { echo("<p>Unable to locate the $database.</p>"); exit(); } // find out how many rows are in the table $sql = mysql_query("SELECT COUNT(*) FROM `gallery` WHERE memberid=$_SESSION[sESS_MEMBER_ID]"); $r = mysql_fetch_row($sql); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 2; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // get the info from the db $sql = "SELECT id, thumb FROM gallery LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); // while there are rows to be fetched... while ($list = mysql_fetch_assoc($result)) { // echo data echo $list['id'] . " : " . $list['thumb'] . "<br />"; } // end while /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?>
-
its still not changing the data based on the page, when i click next now i still get first page?? =(
-
I have a page that paginates results, i have a maximum of 6 per page before it goes to page number 2. now if i have enough results to warrent a page 2 it shows the pagination for 2 pages at tghe bottom. however when i click the number "2" i get the following in my URL results.php?query=SELECT * FROM tests WHERE member_id='1' ORDER BY id DESC LIMIT 0, 8&page=8&limit=8 Here is my results.php page <?php session_start(); include('Includes/auth.php'); require_once('header.php'); $connect = @mysql_connect("$host", "$username", "$password"); if (!($connect)) // If no connect, error and exit(). { echo("<p>Unable to connect to the database server.</p>"); exit(); } if (!(@mysql_select_db($database))) // If can't connect to database, error and exit(). { echo("<p>Unable to locate the $database.</p>"); exit(); } if (!($limit)){ $limit = 4;} // Default results per-page. if (!($page)){ $page = 0;} // Default page value. $numresults = mysql_query("SELECT * FROM gallery WHERE memberid=$_SESSION[sESS_MEMBER_ID]"); // the query. $numrows = mysql_num_rows($numresults); // Number of rows returned from above query. if ($numrows == 0){ include('nogallery.php'); // bah, modify the "Not Found" error for your needs. exit();} $pages = intval($numrows/$limit); // Number of results pages. // $pages now contains int of pages, unless there is a remainder from division. if ($numrows%$limit) { $pages++;} // has remainder so add one page $current = ($page/$limit) + 1; // Current page number. if (($pages < 1) || ($pages == 0)) { $total = 1;} // If $pages is less than one or equal to 0, total pages is 1. else { $total = $pages;} // Else total pages is $pages value. $first = $page + 1; // The first result. if (!((($page + $limit) / $limit) >= $pages) && $pages != 1) { $last = $page + $limit;} //If not last results page, last result equals $page plus $limit. else{ $last = $numrows;} // If last results page, last result equals total number of results. //escape from PHP mode. ?> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf8"/> <title>Index</title> </head> <body class="cloudy"> <table width="80%" border="0" align="center" cellpadding="2" cellspacing="2"> <tr> <td width="40%" valign="top"> <div align="right"><a href="myaccount.php"><img src="img/buttons/my_account.png" alt="" border="0" /></a><img src="img/spacer.png" alt="" width="10" height="1" /><a href="addgallery.php"><img src="img/buttons/upload_image.png" alt="" border="0" /></a><img src="img/spacer.png" alt="" width="10" height="1" border="0" /></div> <div class="content-box column-left"> <div class="content-box-header"> <h3>My Gallery</h3> </div><div class="content-box-content"><div><h4></h4> <table width="100%" border="0" cellpadding="0" cellspacing="4"> <tr> <td align="center" valign="top"><div><div> <h2>Showing <strong><?=$first?></strong> - <strong><?=$last?></strong> of <strong><?=$numrows?></strong></h2> </div> <table width="100%" border="0" cellspacing="4" cellpadding="4"> <?php $query = "SELECT * FROM gallery WHERE memberid='$_SESSION[sESS_MEMBER_ID]' ORDER BY id DESC LIMIT $page, $limit"; $result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error()); if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 4; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; // reduces month output data to 3 digits $month=substr($month,0,3); // make sure we have a valid output if($id != "" && $id != null) echo "<td><table class='sample' width='85%' border='0' cellspacing='0' cellpadding='6'><tr align='center' height='100%' /><td height='220'><table height='100%' border='0' cellspacing='0' cellpadding='4'><tr><td>"; echo "<strong><span class='medium_text'>{$row['caption']}</span></strong></td></tr>"; //echo "<br />"; echo "<tr><td align='center' valign='middle'><a href='{$row['image']}' rel='facebox'><img class='gallery' src='{$row['thumb']}' /></a></td></tr>"; //echo "<br>"; echo "<tr><td><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td><img src='img/icons/date.png' /> {$row['date']}</td><td><a href='remove-confirm.php?ID=<?php echo $encoded ?>' rel='facebox'><img src='img/icons/delete2.png' border='0' alt='Delete these results'/></a></td></tr></table></td></tr></table></td></tr></table>"; echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i < $max_columns) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; } ?> </tr> </table> <div align="center"><br> <?php if ($page != 0) { // Don't show back link if current page is first page. $back_page = $page - $limit; echo("<a href=\"$PHP_SELF?query=$query&page=$back_page&limit=$limit\">« Previous</a> \n");} for ($i=1; $i <= $pages; $i++) // loop through each page and give link to it. { $ppage = $limit*($i - 1); if ($ppage == $page){ echo("<b>$i</b> \n");} // If current page don't give link, just text. else{ echo("<a href=\"$PHP_SELF?query=$query&page=$ppage&limit=$limit\">$i</a> \n");} } if (!((($page+$limit) / $limit) >= $pages) && $pages != 1) { // If last page don't give next link. $next_page = $page + $limit; echo("<a href=\"$PHP_SELF?query=$query&page=$next_page&limit=$limit\">Next »</a>\n");} ?> </div> </div></td> </tr> </table> </td> </tr> </table> <?php require_once('footer.php'); ?> </body> </html> i have been editing code and must of changed something previously and forgot to error check this page. but i cant find what i have changed. can someone see if i forgot something or removed something for me as i cant see where to look? many thanks.
-
yes
-
voip03 thank you for the help and the code snippets, between yours and mine i managed to acomplish my need perfectly. although when i upload a transparent PNG it adds a black background, but tbh i can prob live with it.
-
works a treat, now how do i get the rename sorted how i had on my old code above into this one? //Assign Random number & the member_id from session $rand = mt_rand(1,9999999); $member_id = $_SESSION['SESS_MEMBER_ID']; //Rename the file for example "85674_1.jpg" $newFileName = $rand . "_" . $member_id.$ext; my current working code: <?php session_start(); include('Includes/auth.php'); require_once('header.php'); error_reporting(0); $change=""; $abc=""; $rand = mt_rand(1,9999999); $member_id = $_SESSION['SESS_MEMBER_ID']; define ("MAX_SIZE","950"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if($_SERVER["REQUEST_METHOD"] == "POST") { $image =$_FILES["file"]["name"]; $uploadedfile = $_FILES['file']['tmp_name']; $caption = $_POST["caption"]; if ($image) { $filename = stripslashes($_FILES['file']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $change='<div class="notification attention png_bg"> <a href="#" class="close"><img src="img/cross_grey_small.png" title="Close this notification" alt="close" /></a> <div>Unknown Image extension<br> </div> </div> '; $errors=1; } else { $size=filesize($_FILES['file']['tmp_name']); if ($size > MAX_SIZE*1024) { $change='<div class="notification attention png_bg"> <a href="#" class="close"><img src="img/cross_grey_small.png" title="Close this notification" alt="close" /></a> <div>You have exceeded the size limit!<br> </div> </div> '; $errors=1; } if($extension=="jpg" || $extension=="jpeg" ) { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); } else if($extension=="png") { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefrompng($uploadedfile); } else { $src = imagecreatefromgif($uploadedfile); } echo $scr; list($width,$height)=getimagesize($uploadedfile); $newwidth=650; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); $newwidth1=150; $newheight1=($height/$width)*$newwidth1; $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "gallery/". $_FILES['file']['name']; $filename1 = "gallery/thumb/small". $_FILES['file']['name']; imagejpeg($tmp,$filename,100); imagejpeg($tmp1,$filename1,100); imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); }} } //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { $result = mysql_query("INSERT INTO `gallery` (`image`, `thumb`,`memberid`, `caption`) VALUES ('$filename', '$filename1', '$member_id', '$caption')") or die (mysql_error()); $change=' <div class="notification success png_bg"> <a href="#" class="close"><img src="img/cross_grey_small.png" title="Close this notification" alt="close" /></a> <div>Image Uploaded Successfully!<br> </div> </div>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf8"/> <title>Index</title> </head> <body class="cloudy"> <table width="80%" border="0" align="center" cellpadding="2" cellspacing="2"> <tr> <td width="40%" valign="top"> <div align="right"><a href="account.php"><img src="img/buttons/my_account.png" alt="" border="0" /></a><img src="img/spacer.png" alt="" width="10" height="1" /><a href="gallery.php"><img src="img/buttons/my_gallery.png" alt="" border="0" /></a><img src="img/spacer.png" alt="" width="10" height="1" border="0" /></div> <div class="content-box"> <div class="content-box-header"> <h3>Add Gallery Photo</h3> </div> <div class="content-box-content"> <div> <table width="100%" border="0" cellspacing="0" cellpadding="6"> <tr> <td colspan="7" valign="top"> <form method="post" action="" enctype="multipart/form-data" name="form1"> <table border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="2"><?php echo $change; ?></td> </tr> <tr> <td>Picture: </td> <td> <div align="left"> <input size="25" name="file" type="file"/> </div></td> </tr> <tr><td></td> <td>Image maximum size <b>950 </b>kb</span></td> </tr> <tr> <td>Caption: </td> <td><input class="text" name="caption" type="text" value="" /></td> </tr> <tr><td></td><td><input type="submit" id="mybut" value=" Upload " name="Submit"/></td></tr> <tr> <td> </td> <td> </td> </tr> </table> </form> </td> </tr> </table> </p> </div> </div> </td> </tr> </table> <?php require_once('footer.php'); ?> </body> </html>
-
these are my 2 pages: add.php <?php $rand = mt_rand(1,9999999); $member_id = $_SESSION['SESS_MEMBER_ID']; $caption = $_POST["caption"]; if(isset($_FILES['uploaded']['name'])) { $allowed_filetypes = array('.jpg','.gif','.bmp','.png','.jpeg'); $max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5MB) $filename = basename($_FILES['uploaded']['name']); $errors = array(); $target = "gallery/"; $fileBaseName = substr($filename, 0, strripos($filename, '.')); // Get the extension from the filename. $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); //$newfilename = md5($fileBaseName) . $ext; $newfilename = $target . $rand . "_" . $member_id.$ext; // Check if filename already exists if(file_exists("gallery/" . $newfilename)) { $errors[] = "The file you attempted to upload already exists, please try again."; } // Check if the filetype is allowed. if(!in_array($ext,$allowed_filetypes)) { $errors[] = "The file you attempted to upload is not allowed."; } // Now check the filesize. if(!filesize($_FILES['uploaded']['tmp_name']) > $max_filesize) { $errors[] = "The file you attempted to upload is too large."; } // Check if we can upload to the specified path. if(!is_writable($target)) { $errors[] = "You cannot upload to the specified directory, please CHMOD it to 777."; } //Here we check that no validation errors have occured. if(count($errors)==0) { //Load Class File to resize images include('Includes/SimpleImage.php'); //Load image to resize $image = new SimpleImage(); $image->load($_FILES['uploaded']['tmp_name']); $image->resizeToWidth(25); //Try to upload it. if(!move_uploaded_file($_FILES['uploaded']['tmp_name'], $newfilename)) { $errors[] = "Sorry, there was a problem uploading your file."; } } //Lets INSERT database information here if(count($errors)==0) { $result = mysql_query("INSERT INTO `gallery` (`image`, `memberid`, `caption`) VALUES ('$newfilename', '$member_id', '$caption')") or die (mysql_error()); } //If no errors show confirmation message if(count($errors)==0) { echo "<div class='notification success png_bg'> <a href='#' class='close'><img src='img/cross_grey_small.png' title='Close this notification' alt='close' /></a> <div> Image has been uploaded.<br>\n </div> </div>"; //echo "The file {$filename} has been uploaded"; echo "<br>\n"; echo "<a href='gallery.php'>Go Back</a>\n"; } else { //show error message echo "<div class='notification attention png_bg'> <a href='#' class='close'><img src='img/cross_grey_small.png' title='Close this notification' alt='close' /></a> <div> Sorry your file was not uploaded due to the following errors:<br>\n </div> </div>"; //echo "Sorry your file was not uploaded due to the following errors:<br>\n"; echo "<ul>\n"; foreach($errors as $error) { echo "<li>{$error}</li>\n"; } echo "</ul>\n"; echo "<br>\n"; echo "<a href='gallery.php'>Go Back</a>\n"; } } else { //Show the form echo "Use the following form below to add a new image to your gallery;<br /><br />\n"; echo "<form enctype='multipart/form-data' action='' method='POST'>\n"; echo "Please choose a file:<br /><input class='text' name='uploaded' type='file' /><br />\n"; echo "Image Caption:<br /><input class='text' name='caption' type='text' value='' /><br /><br />\n"; echo "<input class='Button' type='submit' value='Upload' />\n"; echo "</form>\n"; } ?> Includes/SimpleImage.php <?php /* * File: SimpleImage.php * Author: Simon Jarvis * Copyright: 2006 Simon Jarvis * Date: 08/11/06 * Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details: * http://www.gnu.org/licenses/gpl.html * */ class SimpleImage { var $image; var $image_type; function load($filename) { $image_info = getimagesize($filename); $this->image_type = $image_info[2]; if( $this->image_type == IMAGETYPE_JPEG ) { $this->image = imagecreatefromjpeg($filename); } elseif( $this->image_type == IMAGETYPE_GIF ) { $this->image = imagecreatefromgif($filename); } elseif( $this->image_type == IMAGETYPE_PNG ) { $this->image = imagecreatefrompng($filename); } } function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image,$filename,$compression); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image,$filename); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image,$filename); } if( $permissions != null) { chmod($filename,$permissions); } } function output($image_type=IMAGETYPE_JPEG) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image); } } function getWidth() { return imagesx($this->image); } function getHeight() { return imagesy($this->image); } function resizeToHeight($height) { $ratio = $height / $this->getHeight(); $width = $this->getWidth() * $ratio; $this->resize($width,$height); } function resizeToWidth($width) { $ratio = $width / $this->getWidth(); $height = $this->getheight() * $ratio; $this->resize($width,$height); } function scale($scale) { $width = $this->getWidth() * $scale/100; $height = $this->getheight() * $scale/100; $this->resize($width,$height); } function resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); $this->image = $new_image; } } ?>
-
i saw that from line 44 > 105 it tried to pullvariable $filename where i had $fileName (capital) n, i changed that in my code but still not processing the function class. how can i get it to produce error checks and echo them?