Jump to content

Gem

Members
  • Posts

    129
  • Joined

  • Last visited

About Gem

  • Birthday April 14

Profile Information

  • Gender
    Female
  • Location
    Bristol, England
  • Interests
    Sports, Martial Arts, PHP and coding

Gem's Achievements

Member

Member (2/5)

0

Reputation

  1. Gem

    Hello All!

    Welcome to the freaks Lewis
  2. The class ($this) does not have the function isPost() ...
  3. Can my name be changed to Gem please, or GemGale if Gem is already taken? Im always on IRC as Gem Thank you
  4. Alternatively someone post all the logs where Alexi is rude and condescending to almost everyone who she talks to, people who are usually trying to help her. Frost is a very helpful and friendly member of the community, and a very good op in IRC, and to see him being "reported" is just not cool.
  5. var_dump($_POST['title']); you might want to add method="post" to your form tag though ...
  6. <?php $cnn = mysql_connect("localhost","root",""); mysql_select_db("hms",$cnn); $month=$_GET['q']; $html = "<strong>$month</strong> Month Report"; //$string="2004-12-28"; $result=mysql_query("SELECT monthname(date) As newd FROM stock_entries WHERE monthname(date)='".$month."' "); if(!$result) die(mysql_error()); $html .= "<table border='1'>"; while($row = mysql_fetch_array($result)) { $html.= "<tr>"; // echo "<td>" . date("m",strtotime($row['date'])) . "</td>"; $html .= "<td>" . $row['newd'] . "</td>"; //echo "<td>" . $row[''] . "</td>"; //echo "<td>" . $row[''] . "</td>"; //echo "<td>" . $row[''] . "</td>"; $html .= "</tr>"; } $html .= "</table>"; echo $html; ?>
  7. Gem

    Query help please?

    I forgot to say, I'm struggling because I need to paginate the comments. I need to page only at a parent, i.e not splitting child comments over seperate pages (planning to use js to show/hide the replies) so I'm wanting like say 5 parent comments, plus all their children per page. This is why I'm looking for a query to put them in the right order ...
  8. Hi guys, Was wondering if someone could help me with a query. Here is my table structure: commID int(11) postID int(4) replyto int(6) depth int(2) timestamp int(11) name varchar(100) email varchar(100) comment text So what I'm trying to get is the comments in order. The order I need is: comment 1 - parent comment 2 - parent comment 5 - reply to comment 2 comment 6 - another reply to comment 2 comment 7 - reply to comment 6 which is a reply to comment 2 comment 3 - parent comment 4 - reply to comment 3 and so on. There is no limit to how many levels of children there can be per parent. I'm hoping this makes sense :S Can you help? Many thanks Gem
  9. Thank you, I read it, and tried to implement it, but now the whole thing doesnt work ... all I got is a blank page? I've obviously done it wrong ... can someone please look at this code and if poss. debug it? I've spent an hour looking at it and I cant find the problem (i've commented it to make it easier to read) <?php // database stuff ini_set("memory_limit","120M"); include ("dbconnect"); include ("check admin"); // check user is an admin, if not return to log in screen if ($admin != 1) { header("location:./login.php"); } // if user is an admin, do this ... else { // define a maximum sizes for the uploaded images define ("MAX_SIZE","5000"); define ("WIDTH","150"); define ("HEIGHT","100"); // Get extention function function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // *********************************************************************** Create the thumnail ******************************************************** function make_thumb($img_name,$filename,$new_w,$new_h) { // get extension $ext=getExtension($img_name); if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext)) $src_img=imagecreatefromjpeg($img_name); if(!strcmp("png",$ext)) $src_img=imagecreatefrompng($img_name); // gets the dimmensions of the image $old_x=imageSX($src_img); $old_y=imageSY($src_img); // Calculate new dimentions $ratio1=$old_x/$new_w; $ratio2=$old_y/$new_h; if($ratio1>$ratio2) { $thumb_w=$new_w; $thumb_h=$old_y/$ratio1; } else { $thumb_h=$new_h; $thumb_w=$old_x/$ratio2; } // create a new image with the new dimmensions $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); // resize the original image to the new created one imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); // output the created image to the file. Now we will have the thumbnail into the file named by $filename if(!strcmp("png",$ext)) imagepng($dst_img,$filename); else imagejpeg($dst_img,$filename); //destroys source and destination images. imagedestroy($dst_img); imagedestroy($src_img); } //****************************************************************END create thumbnail ********************************************************* // Error Check! $errors=0; if(isset($_POST['submit1']) && !$errors) { $sqlalbum="INSERT INTO album (album_name) VALUES ('$_POST[newalbumname]')"; mysql_query($sqlalbum) or die ('Error, album_query failed : ' . mysql_error()); } foreach ($_FILES['image']['name']{// ----------------------check the form has been submitted------------------------ if(isset($_POST['Submit'])) { // .................................................................... foreach() ?????? LOOOOOOOOPPPPP START ??? //read the name of the file submitted $image=$_FILES['image']['name']; //...............................array here????? // if it is not empty if ($image) { // get the original name $filename = stripslashes($_FILES['image']['name']); // get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); // if it is not a jpg, jpeg or png show error and dont upload if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { echo '<h1>Unknown extension! You can only upload jpg, jpeg and png files</h1>'; $errors=1; } // if its ok .... else { // get the size of the image in bytes $size=getimagesize($_FILES['image']['tmp_name']); $sizekb=filesize($_FILES['image']['tmp_name']); //compare the size with the maximum size we defined and print error if bigger if ($sizekb > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } //give the image a unique name $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="uploads/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); //we verify if the image has been uploaded, and print error instead if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; } else { // the new thumbnail image will be placed in images/thumbs/ folder $thumb_name='uploads/thumbs/thumb_'.$image_name; // call the function that will create the thumbnail. The function will get as parameters //the image name, the thumbnail name and the width and height desired for the thumbnail $thumb=make_thumb($newname,$thumb_name,WIDTH,HEIGHT); }} }} //If no errors registred, print the success message and show the thumbnail image created if(isset($_POST['Submit']) && !$errors) { $album = $_POST['album']; $query = "INSERT INTO upload (name, path, album_id, thumbpath ) ". "VALUES ('$image_name', '$newname' , '$album', '$thumb_name')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); echo "<h1>Thumbnail created Successfully!</h1>"; echo '<img src="'.$thumb_name.'">'; } // END LOOOPPPPPP ???? } ?> <!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"><!-- InstanceBegin template="/Templates/templ8t.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="css/layout.css" rel="stylesheet" type="text/css" /> <link href="css/text.css" rel="stylesheet" type="text/css" /> <!-- InstanceBeginEditable name="doctitle" --> <title>Bradley Stoke Judo Club</title> <!-- InstanceEndEditable --> <!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> <style type="text/css"> <!-- .style1 {color: #FFFFFF} .H2 { font-size: x-large; font-family: Arial, Helvetica, sans-serif; background-color: #FFFF00; } .link {color: #FFFF33} --> </style> </head> <body> <?php echo $errors; ?> <div class="wrapper"> <div class="header"> </div> <div class="body"> <!-- InstanceBeginEditable name="bodytext" --> <center> <span class="pagetitle">Upload New Images</span><br /> <h1> Step 1 </h1> Check that the album you wish to add a image to exists in the list below ( -Albums- ).<br /> If not - add a new album name here... <form name="newalbum" method="post" action=""> <input name="newalbumname" type="text" size="30" maxlength="30" value="<?php echo $newalbumname; ?>" /> <input type="submit" name="submit1" value="Create Album" /> </form> <h1> Step 2 </h1> If the album exists (or you just created one) select it from the list below. Click browse - find the image you want - press upload.<br /> You should see a thumbnail of the image above if it worked. Add another image if necessary <br /> <form name="newad" method="post" enctype="multipart/form-data" action=""> <table> <tr><td><select name="album"> <option value="select" selected="selected" >-Albums-</option> <?php $asql="select * from album order by album_id DESC"; $aresult=mysql_query($asql) or die(mysql_error());; while($arow=mysql_fetch_array($aresult)) { $album_id=$arow['album_id']; $album_name=$arow['album_name']; ?> <option value="<?php echo $album_id; ?>"><?php echo $album_name; ?></option> <?php } ?> </select> <tr><td><input type="file" name="image[]" ></td></tr> <tr><td><input type="file" name="image[]" ></td></tr> <!-- <tr><td><input type="file" name="image[]" ></td></tr> <tr><td><input type="file" name="image[]" ></td></tr> <tr><td><input type="file" name="image[]" ></td></tr> <tr><td><input type="file" name="image[]" ></td></tr> <tr><td><input type="file" name="image[]" ></td></tr> <tr><td><input type="file" name="image[]" ></td></tr> <tr><td><input type="file" name="image[]" ></td></tr> <tr><td><input type="file" name="image[]" ></td></tr> --> <tr><td><input name="Submit" type="submit" value="Upload image"></td></tr> </table> </form> <!-- InstanceEndEditable --> </div> <div class="sidebar"> <!-- MENU --> <BR><?php include "includes/menujs.js"; include "includes/menucss.css"; include "includes/menu.html"; ?> </p> <p> <!-- InstanceBeginEditable name="sidebar2" --> <div class="sidebartitle" align="center"> Quick Links</div> <div class="sidebartext" align="center"> <br /><a href="index.php"><h2>Home</h2></a><br /> <?php if ($user != "y") { $login_text = "Login"; } else { $login_text = "Logout"; } ?> <a href="login.php"><h2><?php echo $login_text; ?></h2></a><br /> <?php if ($user == "y"){ ?> <a href="profile.php?username=<?php echo $username; ?>"><h2>Back to Profile</h2></a><br /> <?php } ?> </div> <div class="sidebartitle" align="center"> Sponser </div> <div class="sidebartext" align="center"> <img src="images/proemblogo.jpg" alt="professionalembroidery" /></div> <!-- InstanceEndEditable --> </p> </div> </div> <div class="clear"></div> <div class="copyright"> <div align="center" class="style1">©Copyright 2010 Bradley Stoke Judo Club || Site Designed by Gem Gale || Site Hosted by <a href="http://www.wotwebsystems.com" class="link">WOT Web Systems</a></div> </div> <?php if ($con) { mysql_close($con);} ?> </body> <!-- InstanceEnd --></html> <?php } ?>
  10. Hi everybody I am new to arrays, and loops pretty much, so please dont be mean! I am trying to turn a single upload form into a multiple upload form. My logic is I need to use arrays and loop the code for uploading the data from the form to the database (for each of these files, create a thumbnail, resize and rename original, move to folder, create path, and insert all that information into the db) But I have no idea how I've got this in the form (now) .... <pick an album to put the files into> <input type="file" name="image[]" > <input type="file" name="image[]" > and this is the code for the whole upload. It worked for single uploads ... but I'm now at a loss ... The code is abit messy, sorry. I'm fairly sure I need a foreach loop, but I dont know where to put it Really Really hoping you can help. Many thanks in advance <?php ini_set("memory_limit","120M"); include ("DBCONNECT"); include ("CHECK ADMIN"); if ($admin != 1) { header("location:./login.php"); } else { define ("MAX_SIZE","5000"); define ("WIDTH","150"); define ("HEIGHT","100"); function make_thumb($img_name,$filename,$new_w,$new_h) { $ext=getExtension($img_name); if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext)) $src_img=imagecreatefromjpeg($img_name); if(!strcmp("png",$ext)) $src_img=imagecreatefrompng($img_name); $old_x=imageSX($src_img); $old_y=imageSY($src_img); $ratio1=$old_x/$new_w; $ratio2=$old_y/$new_h; if($ratio1>$ratio2) { $thumb_w=$new_w; $thumb_h=$old_y/$ratio1; } else { $thumb_h=$new_h; $thumb_w=$old_x/$ratio2; } $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); Imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); if(!strcmp("png",$ext)) imagepng($dst_img,$filename); else imagejpeg($dst_img,$filename); imagedestroy($dst_img); imagedestroy($src_img); } function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if(isset($_POST['submit1']) && !$errors) { $sqlalbum="INSERT INTO album (album_name) VALUES ('$_POST[newalbumname]')"; mysql_query($sqlalbum) or die ('Error, album_query failed : ' . mysql_error()); } If(isset($_POST['Submit'])) { $image=$_FILES['image']['name']; // if it is not empty if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { echo '<h1>Unknown extension! You can only upload jpg, jpeg and png files</h1>'; $errors=1; } else { $size=getimagesize($_FILES['image']['tmp_name']); $sizekb=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($sizekb > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } $image_name=time().'.'.$extension; $newname="uploads/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; } else { $thumb_name='uploads/thumbs/thumb_'.$image_name; $thumb=make_thumb($newname,$thumb_name,WIDTH,HEIGHT); }} }} If(isset($_POST['Submit']) && !$errors) { $album = $_POST['album']; $query = "INSERT INTO upload (name, path, album_id, thumbpath ) ". "VALUES ('$image_name', '$newname' , '$album', '$thumb_name')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); echo "<h1>Thumbnail created Successfully!</h1>"; echo '<img src="'.$thumb_name.'">'; } ?>
  11. Wow - That looks pretty complicated! Anyway, I uploaded the code, fixed a couple of syntex errors but I get a HTTP500 You know where you wrote //generate where clause ... amI supposed to write something there?? Am such a noob, sorry!! x
  12. im not very good at explaining things ... did u take a look at the page? ummm ... when you select something in the dropdown boxes, itwill query the database and then display the results underneath. when you select a competition, and leave the others SHOWALL, it displays all the results from that competition i.e. Gem - World Masters - 2010 - Gold Pete - World Masters - 2010 - Gold Nick - World Masters - 2008 - Silver When you select a competition and year (i.e.world masters and 2010) - you see the 2 results BUT If you only select Pete, nothing shows. And if you select only 2010, nothing shows .... Does that help?? xx
  13. when you submit the form, whats in the address bar?
×
×
  • 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.