PHP - Php (gd) - Applying Image Changes In Order Not Working, Imagefill Won't Fill
I have a black and white image dividing a city into zip codes. So a bunch of shapes and that's it.
I load it (imagecreatefrompng) and I'm filling the zipcodes with color based on coordinates of a spot in the zipcode and a color relevant to information about it.
If I use imagefill (or imagefilltoborder) to fill a zip code it works great.
But - I also need to apply text and lines to that image on top of those filled shapes.
My problem is it's always doing the fill last no matter what order I put it in the code - so anywhere a line crosses a zipcode it only gets half filled in.
For example I attached an image - if i turn off the lines the white box is filled in with a shade of red. Not a great example since I think the line is right on top of the coordinate of the fill but it does it all over the image.
What am I missing? Is there not a way to choose the order your draw to the image object? Is there a way to apply a change before doign the next one short of writing and reloading the file? Similar TutorialsCurrently I have where the User can search for records, then the records are displayed on a page. I then have a drop down box to where the user can Order by 2 different categories to make it easier for the user to see things but for some reason it is not working. Here is my code. Oh and the error I get is mysql_num_rows(): supplied argument is not a valid MySQL result resource in <?php $qry_str="SELECT * FROM timeslip WHERE 1 "; if($_POST['Initials']) { $Initials=$_POST['Initials']; $qry_str.="and Initials='$Initials' "; } if($_POST['Identifier']) { $Identifier=$_POST['Identifier']; $qry_str.="and Identifier LIKE '%$Identifier%' "; } if($_POST['Type']) { $Type=$_POST['Type']; $qry_str.="and Type LIKE '%$Type%' "; } if($_POST['Terms']) { $Terms=$_POST['Terms']; $qry_str.="and Terms LIKE '%$Terms%' "; } if($_POST['Memo']) { $Memo=$_POST['Memo']; $qry_str.="and Memo LIKE '%$Memo%' "; } if($_POST['date1']) { $date1=$_POST['date1']; $date2=$_POST['date2']; $start=date('Y-m-d', strtotime($date1)); $end=date('Y-m-d', strtotime($date2)); $qry_str.="and Date >= '$start' and Date <= '$end' "; } if($_POST['order1'] && $_POST['order2']) { $order1=$_POST['order1']; $order2=$_POST['order2']; $qry=$_POST['qry']; $qry_str="$qry ORDER BY $order1 ASC, $order2 ASC "; } if($_POST['order1']) { $order1=$_POST['order1']; $qry=$_POST['qry']; $qry_str="$qry ORDER BY $order1 ASC"; } if($_POST['order2']) { $order2=$_POST['order2']; $qry=$_POST['qry']; $qry_str="$qry ORDER BY $order2' ASC "; } $result=mysql_query($qry_str); $count=mysql_num_rows($result); if ($count>0){ ?> <form action="" method="post"> <input type="hidden" value="<?=$qry_str?>" name="qry"/> Order Results By <select name="order1" > <OPTION value="<?=$order1?>"><?=$order1?></OPTION> <OPTION value="Identifier">Identifier</OPTION> <OPTION value="Type">Type</OPTION> <OPTION value="Terms">Terms</OPTION> <OPTION value="Date">Date</OPTION> <OPTION value="Cost">Cost</OPTION> </select> Then <select name="order2" > <OPTION value="<?=$order2?>"><?=$order2?></OPTION> <OPTION value="Identifier">Identifier</OPTION> <OPTION value="Type">Type</OPTION> <OPTION value="Terms">Terms</OPTION> <OPTION value="Date">Date</OPTION> <OPTION value="Cost">Cost</OPTION> </select> <input type="submit" name="submit"> </form> I have a basic query where I am retrieving project records. I basically want to show the records from newest to oldest, but I also want to show the Featured projects first. Each Featured project is marked by "1" in the mysql table column. If it's not featured, then it's marked "0". $find_records = $db->prepare("SELECT * FROM projects ORDER BY project_id DESC, featured DESC LIMIT 10"); $find_records->execute(); $result_records = $find_records->fetchAll(PDO::FETCH_ASSOC); if(count($result_records) > 0) { foreach($result_records as $row) { } } The issue with above query is that the ORDER BY works only for the first component(project_id) and ignores the second component(featured). Do you see what's wrong with it? This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=318036.0 Ok, so I used to be very good in HTML, PHP, and JS, but it's been a long time since I used it. been trying to make just a simple order form for a friends business. Though I wanted it to do server side validation and emailing... But it doesn't do anything.... on submit I get no errors when there are and with no errors I get no email to my inbox.. What it is supposed to do is gather what pictures they checked and their sizes as well as a person info and email it to an email address. Though I want it to check for required areas and correct input (like email has @ and a .com in it, zip is digits only, etc... But yeah my code shows the order form and looks nice, but does nothing.... Code: [Select] <?php require_once "formvalidator.php"; $error_hash = 'no'; $show_form = true; class MyValidator extends CustomValidator { function DoValidate(&$formars,&$error_hash) { if(stristr($formars['comments'],'http://')) { $error_hash['comments']="No URLs allowed in comments"; return false; } return true; } } if (isset($_REQUEST['Submit'])) { $validator = new FormValidator(); $validator->addValidation("email", "email", "<B>Email address is invalid.</B>"); $validator->addValidation("first", "req", "<B>Please provide your first name for invoice.</B>"); $validator->addValidation("addr", "req", "<B>Please provide your address for invoice.</B>"); $validator->addValidation("city", "req", "<B>Please provide your city name for invoice.</B>"); $validator->addValidation("zip", "req", "<B>Please provide your zipcode for invoice.</B>"); $validator->addValidation("last", "req", "<B>Please provide your last name for invoice.</B>"); $validator->addValidation("zip", "num", "<B>Numbers only in Zipcode.</B>"); $validator->addValidation("phone", "num", "<B>Numbers only in phone number.</B>"); if ($validator->ValidateForm()) { $show_form = false; } else { echo "<center><font color='#CC0000'><B>Validation Errors:</B></font></center>"; $error_hash = $validator->GetErrors(); foreach ($error_hash as $inpname => $inp_err) { echo "<center><p>$inpname : $inp_err</p></center>\n"; $show_form = true; } } if ($show_form === false){ // Grab the form vars $Pic = $_REQUEST['pic[]'] ; $Size = $_REQUEST['size[]'] ; $Email = $_REQUEST['email']; $Name = $_REQUEST['first'. 'last']; $Addr = $_REQUEST['addr']; $City = $_REQUEST['city']; $State = $_REQUEST['state']; $Zip = $_REQUEST['zip']; $comments = $_REQUEST['comments'] ; if(empty($pic)) { echo "<center><font color='#CC0000'><B>Please Select a picture.</B></font></center>"; } else { $r = count($pic); for($i=0; $i < $r; $i++) { echo "picture(s) requested $i was: " . $pic[$i] . "\r\n"; } } if(empty($size)) { echo "<center><font color='#CC0000'><B>Please Select a picture size.</B></font></center>"; } else { $r = count($size); for($i=0; $i < $r; $i++) { echo "Sizes(s) requested $i was: " . $size[$i] . "\r\n"; } } //message body $mail_body .= "$Pic"."\r\n"; $mail_body .= "$Size"."\r\n"; $mail_body .= "$Email"."\r\n"; $mail_body .= "$Name"."\r\n"; $mail_body .= "$Addr"."\r\n"; $mail_body .= "$City,". " $State". " $Zip"."\r\n"; $mail_body .= "$Comments"."\r\n"; //sending to $recipient = "hakarune@gmail.com"; $subject = "Order Form"; //Headerfields $header = "From: " . $Email . " <" . $Email . ">\r\n"; //mail command mail($recipient, $subject, $mail_body, $header); } echo "<div style='width:400px; margin:0 auto; border:1px solid #1e1e1e'>Your order has been sent successfully. <br>An Invoice will be either emailed or mailed to you, thank you for your order.<br>You will be redirected to the home page in a few moments...</div>"; //page redirect to home echo "<meta http-equiv=\"refresh\" content=\"4;url="; echo "http://lmtl-linux/credit\" />"; } if (true == $show_form) { ?> <form name="ordering" action="" method="GET" enctype="text/plain"> <img src="1.jpg" /> <input type="checkbox" name="pic[]" value="1"> <br /> <select name="Type" size="1" name="size[]" Value="1"> <option value="">Select Type</option> <option value="Original">Original $Price</option> <option value="Print Small">300x500 Print $Price</option> <option value="Print Medium">800x600 Print $Price</option> <option value="Print Large">1200x1280 Print $Price</option> <option value="Print XLarge">1282x1400 Print $Price</option> </select> <br /> <img src="2.jpg" /> <input type="checkbox" name="pic[]" value="2"> <br /> <select name="Type" size="1" name="size[]" Value="2"> <option value="">Select Type</option> <option value="Original">Original $Price</option> <option value="Print Small">300x500 Print $Price</option> <option value="Print Medium">800x600 Print $Price</option> <option value="Print Large">1200x1280 Print $Price</option> <option value="Print XLarge">1282x1400 Print $Price</option> </select> <br /> <img src="3.jpg" /> <input type="checkbox" name="size[]" Value="3"> <br /> <select name="Type" size="1" name="size3"> <option value="">Select Type</option> <option value="Original">Original $Price</option> <option value="Print Small">300x500 Print $Price</option> <option value="Print Medium">800x600 Print $Price</option> <option value="Print Large">1200x1280 Print $Price</option> <option value="Print XLarge">1282x1400 Print $Price</option> </select> <br /> <img src="4.jpg" /> <input type="checkbox" name="pic[]" value="4"> <br /> <select name="Type" size="1" name="size[]" Value="4"> <option value="">Select Type</option> <option value="Original">Original $Price</option> <option value="Print Small">300x500 Print $Price</option> <option value="Print Medium">800x600 Print $Price</option> <option value="Print Large">1200x1280 Print $Price</option> <option value="Print XLarge">1282x1400 Print $Price</option> </select> <br /> <img src="5.jpg" /> <input type="checkbox" name="pic[]" value="5"> <br /> <select name="Type" size="1" name="size[]" Value="5"> <option value="">Select Type</option> <option value="Original">Original $Price</option> <option value="Print Small">300x500 Print $Price</option> <option value="Print Medium">800x600 Print $Price</option> <option value="Print Large">1200x1280 Print $Price</option> <option value="Print XLarge">1282x1400 Print $Price</option> </select> <br /> <br /> <br /> Information For Invoice: <font color="red">(Required Info = *)</font> <br /> <input type="text" name="first" Value="First Name" size="25" onfocus="value=''"><font color="red">*</font> <input type="text" name="last" Value="Last Name" size="25" onfocus="value=''"><font color="red">*</font> <br /> <input type="text" name="phone" Value="Phone Number" size="25" onfocus="value=''"> <br /> <input type="text" name="email" Value="E-mail" size="30" onfocus="value=''"> <br /> <input type="text" name="addr" Value="Street Address" size="50" onfocus="value=''"><font color="red">*</font> <br /> <input type="text" name="city" Value="city" size="30" onfocus="value=''"><font color="red">*</font> <br /> <select name="state" size="1"> <option value="">Select State</option> <option value="AK">AK</option> <option value="AL">AL</option> <option value="AR">AR</option> <option value="AZ">AZ</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DC">DC</option> <option value="DE">DE</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="IA">IA</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="MA">MA</option> <option value="MD">MD</option> <option value="ME">ME</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MO">MO</option> <option value="MS">MS</option> <option value="MT">MT</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="NE">NE</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NV">NV</option> <option value="NY">NY</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VA">VA</option> <option value="VT">VT</option> <option value="WA">WA</option> <option value="WI">WI</option> <option value="WV">WV</option> <option value="WY">WY</option> </select> <br /> <input type="text" name="zip" Value="Zipcode" size="5" onfocus="value=''"><font color="red">*</font> <br /> <textarea name="comments" rows="15" cols="40" value="comments" onfocus="value=''"> </textarea> <br /> <input type=button value="Submit"> <input type="reset" value="Clear Form"> </form> <?php }//true == $show_form ?> This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=332593.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=328623.0
Hi everyone. I'm very new into self learning programming. Presently I'm trying to develop a simple basic Robot that would only Place a Market Order every seconds and it will cancel the Order every followed seconds. Using the following library: It would place Trade Order at a ( Price = ex.com api * Binance api Aggregate Trades Price) I have already wrote the api to call for xe.com exchange rate with php <?php $auth = base64_encode("username:password"); $context = stream_context_create([ "http" => [ "header" => "Authorization: Basic $auth" ] ]); $homepage = file_get_contents("https://xecdapi.xe.com/v1/convert_from?to=NGN&amount=1.195", false, $context ); $json = json_decode($homepage, TRUE); foreach ($json as $k=>$to){ echo $k; // etc }; ?> And also for the Binance Aggregate Price in JavaScript
<script> var burl = "https://api3.binance.com"; var query = '/api/v3/aggTrades'; query += '?symbol=BTCUSDT'; var url = burl + query; var ourRequest = new XMLHttpRequest(); ourRequest.open('GET',url,true); ourRequest.onload = function(){ console.log(ourRequest.responseText); } ourRequest.send(); </script>
My problem is how to handle these two api responds and also the functions to use them to place a trade and cancel it. I have gold data being reported here goldprices.org.uk (scroll down near the bottom). Recently it broke for no apparent reason. I checked the scraper and everything seems to be OK. The issue is that the gold price in (troy) ounces is being scraped fine - however to work out the price in grams you must multiply by 0.0321 (grams in a troy ounce). The code looks like this: Code: [Select] $ounce_price = null; $grams_price = null; if(count($nodes) == 1 && $nodes[0][1]) { $ounce_price = $nodes[0][1]; $grams_price = $ounce_price * 0.0321; However $ounce_price * 0.0321 breaks the code and returns '0.0321'. I then tried the code: Code: [Select] $ounce_price = null; $grams_price = null; if(count($nodes) == 1 && $nodes[0][1]) { $ounce_price = $nodes[0][1]; $grams_price = $ounce_price + 1; And the code returned the value '2'. So it appears that when $ounce_price is being multiplied/subtracted etc it reverts to a value of '1'. However if I do $grams_price = $ounce_price the value is the correct ounce price. I'm so confused as to why when adding an equation to $ounce_price the value reverts to '1' as opposed to equalling the correct number. Any help here would be HUGELY appreciated - I've been stuck for several days and only just decided to ask online :s Nick ini_set('session.cache_limiter','public'); session_cache_limiter(false);
they give warning
Hi, I'm writing my own code for my website but have come across something I can't fathom and don't know what search terms I'd need to describe what I want, to allow me to Google it. I've got some code that retrieves the image names of pictures inside a directory, that then prints them on the screen as links. Then people can click whichever link to see that pic, and I can just upload new images to the images folder without needing to add the links to the code manually. All is working, but I want to use a table for neatness and put a certain number of the image links in each row. So, say I have 20 images in the folder, but want to display only 5 image links per row in the table, I need 4 rows to be created with 5 links in each one. I know I can use count() to count the number of images found in the folder, but I don't know how to use PHP to make a new row every 5 image links and put the 5 links in the row. This is my code so far: Code: [Select] <?php $dir = '/home/vol7/myhost.com/b12345678/htdocs/images/'; $files = scandir($dir); foreach ($files as $pic) { if (is_dir($dir.$pic)) { unset($pic);} else { echo "$pic"; }} ?> So, if I got it doing what I want, it'd end up outputting something like this if I had 7 image links: Code: [Select] <table> <tr> <td><a href=etc">image 1</a> - <a href=etc">image 2</a> - <a href=etc">image 3</a> - <a href=etc">image 4</a> - <a href=etc">image 5</a></td> </tr> <tr> <td><a href=etc">image 6</a> - <a href=etc">image 7</a></td> </tr> </table> Any help appreciated, even a link to a webpage explaining something similar that gives me enough information to alter it and make it work for what I want. Thanks. Hi, I'm just wondering if there's any way to use the Limit to limit a search to the first instance of multiple items in one column? Eg, in a table called news I might have: subject content general general news1 general generalnews2 faq faq1 faq faq2 general generalnew3 When I do Code: [Select] SELECT * FROM news ORDER BY content DESC LIMIT 0,1(same if I substitute the word subject for content in the line above) ...I get just the first item. Ie: subject content general generalnews1 How would I go about getting the first instance of each subject and its contents to appear? Ie: subject content general generalnews1 faq faq1 Thanks, Dave I've got. Hi guys I am using the code below to upload a series of images to a site, however the records are not being added to the database nor the images being uploaded, but it is doing the redirect at the bottom of the script. Any ideas what is going wrong <?php include('../includes/connect_inc.php'); include("config.inc.php"); set_time_limit(1200); // initialization $result_final = ""; $counter = 0; // List of our known photo types $known_photo_types = array( 'image/pjpeg' => 'jpg', 'image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/bmp' => 'bmp', 'image/x-png' => 'png' ); // GD Function List $gd_function_suffix = array( 'image/pjpeg' => 'JPEG', 'image/jpeg' => 'JPEG', 'image/gif' => 'GIF', 'image/bmp' => 'WBMP', 'image/x-png' => 'PNG' ); // Fetch the photo array sent by preupload.php $photos_uploaded = $_FILES['photo_filename']; // Fetch the photo caption array $photo_caption = $_POST['photo_caption']; while( $counter <= count($photos_uploaded) ) { if($photos_uploaded['size'][$counter] > 0) { if(!array_key_exists($photos_uploaded['type'][$counter], $known_photo_types)) { $result_final .= "File ".($counter+1)." is not a photo<br />"; } else { mysql_query( "INSERT INTO gallery_photos(`photo_filename`, `photo_caption`, `photo_category`) VALUES('0', '".addslashes($photo_caption[$counter])."', '".addslashes($_POST['category'])."')" )or die(mysql_error()); $new_id = mysql_insert_id(); $filetype = $photos_uploaded['type'][$counter]; $extention = $known_photo_types[$filetype]; $filename = $new_id.".".$extention; mysql_query( "UPDATE gallery_photos SET photo_filename='".addslashes($filename)."' WHERE photo_id='".addslashes($new_id)."'" ); // Store the orignal file copy($photos_uploaded['tmp_name'][$counter], $images_dir."/".$filename); // Let's get the Thumbnail size $size = GetImageSize( $images_dir."/".$filename ); if($size[0] > $size[1]) { $thumbnail_width = 100; $thumbnail_height = (int)(100 * $size[1] / $size[0]); } else { $thumbnail_width = (int)(100 * $size[0] / $size[1]); $thumbnail_height = 100; } // Build Thumbnail with GD 1.x.x, you can use the other described methods too $function_suffix = $gd_function_suffix[$filetype]; $function_to_read = "ImageCreateFrom".$function_suffix; $function_to_write = "Image".$function_suffix; // Read the source file $source_handle = $function_to_read ( $images_dir."/".$filename ); if($source_handle) { // Let's create an blank image for the thumbnail $destination_handle = ImageCreate ( $thumbnail_width, $thumbnail_height ); // Now we resize it ImageCopyResized( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1] ); } // Let's save the thumbnail $function_to_write( $destination_handle, $images_dir."/tb_".$filename ); ImageDestroy($destination_handle ); // $result_final .= "<img src='".$images_dir. "/tb_".$filename."' /> File ".($counter+1)." Added<br />"; } } $counter++; } // Print Result header("Location: add-photos.php"); ?> form Code: [Select] <form action="<?php $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" method="post" ><input type="file" name="photo" value="" size="30" /><input type="submit" name="ssubmit" value="Submit" /></form> Code: [Select] $tmpname = $_FILES['photo']['tmp_name']; $readphoto = fopen($tmpname, 'r'); $photo = fread($readphoto, filesize($tmpname)); $photo = addslashes($photo); fclose($readphoto); $query = "INSERT INTO student (PHOTO) ". "VALUES ('$photo')"; mysql_query($query) or die('Error, query failed.'); echo "Student information submitted."; i keep getting "Error, query failed"... what did i do wrong? I asked a question in another thread about making this script work in multiple instances but now I can't even get it to work! Code: [Select] <?php $cpics = array ( "images/sidebar/party1.jpg", "images/sidebar/party2.jpg", "images/sidebar/party3.jpg" ); $index = rand(0, 2); $cbanner = $cpics[$index]; ?> And in the http://do-rightweb.com/1-test.php test page Code: [Select] <img src="$cbanner"> Thanks very much for your help. Hi, I'm making a php game, and the image map isn't working. I don't know if it is a php or javascript issue, I don't think it is an html issue but I could be wrong so feel free to move this post. lol. But basically, The image map is supposed to link to an array of images. That is how the game works. There is the overworld image map, you click on a link, and go to the zone images, all in the same window. Any help GREATLY appreciated because having the image map feature work would be awesome finally. thanks. Derek. here is the code that uses the image map. I cut out a lot of the unnecessary code , but the image map functionality related code is in there. Code: [Select] <?php session_start(); ////////////////////////////////////////////////////////////////////////////////// /////////////////////////////GAME NAVIGATION AND MONSTER SEARCH CODE NOT FINISHED////////////////////////////////// $locations[0] = array(); $locations[1] = array( 'background_images' => array( "<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME2.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME3.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME4.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME5.jpg'/>" ), 'monster_images' => array( "<img src='sundragon_monsters_source/water/goldfish/goldfish.png'/>", "<img src='sundragon_monsters_source/water/eel/eel_transp_FRAME.png '/>", "<img src='sundragon_monsters_source/water/shark/shark_transp_FRAME.png'/>", "<img src='sundragon_monsters_source/water/octalisk/octalisk_transp_FRAME.png'/>", "<img src='sundragon_monsters_source/water/teardrop_ocean_protector/teardrop_ocean_protector.png'/>" ) ); $locations[2] = array( 'backgroundImages' => array( //Array images go here. ) ); if(isset($_GET['newLocation'])) { $_SESSION['current_location']=$_GET['newLocation']; } if(!isset($_SESSION['current_location']) && !isset($_SESSION['current_background']) && !isset($_SESSION['currentMonster'])) { $_SESSION['current_location'] = 0; $_SESSION['current_monster'] = 0; $_SESSION['current_background'] = 0; } if($_SESSION['current_location'] != 0) { if(!isset($_SESSION['current_background']) && !isset($_SESSION['current_monster'])) { $_SESSION['current_monster'] = 0; $_SESSION['current_background'] = 0; } if(isset($_GET['further'])) { //below is- inside the locations array, teardrop ocean (1) the background image is 4(example)+1 is set, then //do this if(isset($locations[$_SESSION['current_location']]['background_images'][$_SESSION['current_background']+1])) { $_SESSION['current_background']+=1; } if(isset($locations[$_SESSION['current_location']]['monster_images'][$_SESSION['current_monster']+1])) { $_SESSION['current_monster']+=1; } } elseif(isset($_GET['back'])) { if(isset($locations[$_SESSION['current_location']]['background_images'][$_SESSION['current_background']-1])) { $_SESSION['current_background']-=1; } if(isset($locations[$_SESSION['current_location']]['monster_images'][$_SESSION['current_monster']-1])) { $_SESSION['current_monster']-=1; } } $currentBackground=$_SESSION['background'][$_SESSION['current_background']]; $currentMonster=$_SESSION['monster'][$_SESSION['current_monster']]; } else { //?newLocation=1 means set it to Teardrop ocean. $currentBackground = ' <img src="aradia.jpg" width="256" height="328" border="0" usemap="#Map" /> <map name="Map" id="Map"> <area shape="rect" coords="5,176,81,249" href="?newLocation=1"/> </map>'; $currentMonster = ''; } /////////////////////////////////////////////////////////////////////////////////////////////////// ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Realm of the Sun Dragon</title> <link rel="stylesheet" type="text/css" href="css/gamestyles.css"> <style type="text/css"> body { margin-top:-32px; padding:0; color: gold; } table { color: black; } .style8 {color: #000000} </style> </head> <body oncontextmenu="return false;"> <div id="container"> <div id="monster_message"> <?php echo "this is the monster battle and NPC talk window";?> </div> <div id="currentWeapon"> <img src="sundragon_interface_template/items/swords/sword_shrunk.png" width="190" height="65" /> </div> <div id="iframe_player_top_lft" > <div id="left_player_stats"><table align="center" width="30" border="0"> <tr> <td><strong>HP</strong></td> <td><strong><font color="red"><?php echo $playerHp;?></font></strong></td> </tr> <tr> <td><strong>MANA</strong></td> <td><strong><font color="green"><?php echo $echoPlayerMana;?></font></td> </tr> <tr> <td><strong>EXP</strong></td> <td><strong><font color="blue">999</font></strong></td> </tr> <tr> <td><strong>PLAT</strong></td> <td><strong><font color="white">999</font></strong></td> </tr> </table></div> <p> </p> <p> </p> <p> </p> <p align="center"><strong><br /> <span class="style8">Octalisk (Level <?php echo $currentMonsterLevel;?>) </span></strong> <br/> <strong><span class="style8">HP</span><font color="red"> <?php echo $monsterHp;?></font></strong> </p> <div id="spelleffectsleft" > <div class="divcenter"> <div align="center"> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> </div> </div> <!--end divcenter--> </div><!--end spell effects--> <div id="bottomspellsleft" > <div class="divcenter"> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> </div> <!--end div center--> </div><!--end bottomspells--> </div><!-- end player div--> <div id="iframe_spell_foreground"><?php echo $echoSpell;?></div> <div id="iframe_monster_background"><?php echo $currentBackground;?></div> <div id="iframe_transparent_monster"><?php echo $currentMonster;?></div> <!--not here--> <div id="iframe_player_top_right" > <table width="160" height="64" border="0" align= "center"> <tr> <td width="160"><div align="center"> <p><strong><br /> Silverglade (Level: <?php echo $currentPLayerLevel;?>)<br /> </strong></p> </div></td> </tr> </table> <div class="spelleffects" > <div class="divcenter"> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> </div> </div> <div class="bottomspells" > <div class="divcenter"> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> <div class="inline"> <div align="center">spell</div> </div> </div> </div> </div> <div id="iframe_chat_right"> the data from the chat message box will be output to this div</div> <!--not here--> <div id="iframe_player_center_bottom" align="center" ><div style="display: inline;"> <form style="display: inline; margin: 0;" ...> <form style="display: inline; margin: 0;" action='gamestart_NEWEST.php' method='post'><input type='submit' name='attack' value='Attack'/><input type="submit" name="search" value="search" /><input type="submit" value="cast spell" name="spell" /><input type="submit" name="inventory" value="Inventory"/></form> <form style="display: inline; margin: 0;" method="get" action=""><input type="submit" value="go further" name="further" /> <input type="submit"value="Go back" name="back"/></form> </form> </div> <div id="chat"> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <strong>Message:</strong> <textarea name="message"></textarea> <input type="submit" name="submit" value="Chat"> <input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>"> </form> </div></div></div> <!--not here--> <div id="log_off"> <a href="logout.php"><strong>LOG OFF</strong></a> </div> <!--not here--> </div> </body> </html> Hey.. this is something I found online, and something mine combined, and it works perfectly... When I upload pic, it uploads it where I want to, and it makes thumbnail where I want to, BUT it resize the original and the thumbnail, so I end up with two same sized images, and I want one thumbnail, and you click it, it shows a bigger ( original ) picture.. Can anyone see an error in this code?? Code: [Select] <?php function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } define ("MAX_SIZE","5000"); $errors=0; if(isset($_POST['submit'])) { $image =$_FILES["file"]["name"]; $uploadedfile = $_FILES['file']['tmp_name']; if ($image) { $filename = stripslashes($_FILES['file']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { echo ' Unknown Image extension '; $errors=1; } else { $size=filesize($_FILES['file']['tmp_name']); if ($size > MAX_SIZE*1024) { echo "You have exceeded the size limit"; $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); } list($width,$height)=getimagesize($uploadedfile); $newwidth=200; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); $newwidth1=200; $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); $thumbnail = "thumbnail". $_FILES['file']['name']; $filename = "upload/". $_FILES['file']['name']; $filename1 = "thumbnail/".$thumbnail; imagejpeg($tmp,$filename,100); imagejpeg($tmp1,$filename1,100); imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); } } } //If no errors registred, print the success message if(!$errors) { header("Location: main.php"); } ?> Hi Guys, I got this method to upload an image once, now nothing is uploading at all and I cant seem to figure out why. I set permissions of both the script and image upload directory to www:/data and 777, but its still not working. When I print the return from basename, it show's 0, which means the file is uploaded.. But it not:( Here is my method. function add_product() { if($_SERVER['REQUEST_METHOD'] == "POST") { //get the form data $data['product'] = array( "name" => $this->input->post('name'), "title" => $this->input->post('title'), "description" => $this->input->post('description'), "status" => $this->input->post('live'), "url" => str_replace(" ", '-',$this->input->post('name')), "preview_image" => $this->input->post('preview_image'), "body_image" => $this->input->post('body_image') ); //add the record the the DB $this->load->model('products_model'); $return = $this->products_model->add_product($data); //upload the images $name = $_FILES['preview_image']['name']; $target = '/var/www/www.example.com/content/product_img/'; $upload = $target.basename($name); switch ($_FILES['preview_image']['error']) { case 1: print '<p> The file is bigger than this PHP installation allows</p>'; break; case 2: print '<p> The file is bigger than this form allows</p>'; break; case 3: print '<p> Only part of the file was uploaded</p>'; break; case 4: print '<p> No file was uploaded</p>'; break; } echo img('content/product_image/'.$name); //upload the images $name2 = $_FILES['body_image']['name']; $target2 = '/var/www/www.example.com/content/product_img/'; $upload2 = $target2.basename($name2); switch ($_FILES['preview_image']['error']) { case 1: print '<p> The file is bigger than this PHP installation allows</p>'; break; case 2: print '<p> The file is bigger than this form allows</p>'; break; case 3: print '<p> Only part of the file was uploaded</p>'; break; case 4: print '<p> No file was uploaded</p>'; break; } echo img('content/product_image/'.$name); //redirect to edit view //redirect('admin/edit_product/'.$return); //testing //print_r($data); } else { $data['title'] = 'Add Product :: FSG'; $data['main_content'] = 'admin/add_product'; $data['user'] = $this->facebook_connect->user; $data['user_id'] = $this->facebook_connect->user_id; $this->load->view('includes/template', $data); } } Here is the html for the form. <form action="<?php echo site_url();?>admin/add_product" method="post" enctype="multipart/form-data"> <div class="fieldset"> <h2 class="legend"> Product Information </h2> <ul class="form-list"> <li class="fields"> <div class="name"> <div class="field"> <label for="name" class="required"><em>*</em>Product Name</label> <div class="input-box"> <input type="text" id="name" name="name" value="New Product" title="Product Name" class="input-text required-entry" /> </div> </div> <div class="field title"> <label for="title" class="required"><em>*</em>Product Title</label> <div class="input-box"> <input type="text" id="title" name="title" value="Title Used On Heading" title="Product Title" class="input-text required-entry" /> </div> </div> </div> </li> <li> <label for="email" class="required"><em>*</em>Product Description</label> <div class="input-box"> <textarea id="description" name="description">Write a 3 to 5 Paragraph summary of product</textarea> </div> </li> <li class="control"> <input type="checkbox" name="live" id="live" value="1" title="Live Product" class="checkbox" /><label for="live_product">Publish Product</label> </li> </ul> </div> <div class="fieldset"> <h2 class="legend"> Product Images </h2> <ul class="form-list"> <li> <label for="preview_image" class="required"><em>*</em>Preview Image :: 240 X 166 Pixels</label> <div class="input-box"> <input type="file" name="preview_image"> </div> </li> <li class="fields"> <div class="field"> <label for="body_image" class="required"><em>*</em>Description Image :: 320 X 320 Pixels</label> <div class="input-box"> <input type="file" name="body_image"> </div> </div> </li> </ul> </div> <div class="buttons-set"> <p class="required"> * Required Fields </p> </p><button type="submit" title="Submit" class="button"><span><span>Submit</span></span></button> </div> </form> Any suggestions for using to php to take html form data and fill a pdf form? Anything for cakephp? Thanks |