Jump to content

dokueki@gmail.com

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Everything posted by dokueki@gmail.com

  1. C'mon, I hate bumping, but I kinda need this =\ I've tried fixing it further but no luck.
  2. Just rewrite the array without the first 3 elements (the first row). <?php $elements_copy = $elements; for ($i = 2; $i < count($elements); $i++) $elements[$i-2] = $elements_copy[$i]; ?> Or something like that, I didn't exactly look through the whole code, I'm assuming you'd change the variables to whatever suits you.
  3. Use a for loop? <?php for ($j=1; $j <= count($ticket); $j++) { echo ' <td>Ticket Status: '.$ticket['step_status'.$j].'</td>'; } ?> Or something similar to that.
  4. Error messages? oO HTML isn't supposed to produce errors, it just looks at you weird. Uhm, fix your coding habits, they hurt my eyes. And how's this related to PHP?
  5. Replace <?php echo $history; ?> with '.$history.' (Including quotes and everything)
  6. You could always just make sure no one you don't want to gets permission to do this, so you just need to make sure they're logged in and have the right permissions before letting the delete script actually run. I suggest cookies or session, check if they have the right power to delete, like if they have a certain permission (like moderator) or are the owners of the picture. Or do you mean you have no delete permissions at all?
  7. Sure, it should be... <?php mysql_query("DELETE FROM `pictures` WHERE `picture_id` = 'ID' LIMIT 1"); Don't forget to replace ID with the actual ID or variable that points to it.
  8. Also, looks like you forgot to add the single quote at start, correct me if I'm wrong, <?php if($secret == "89"){ $content .= ' <form id="news" form action="history_edit.php" method="post"> <table width="500" border="0"> <tr> <td colspan="2" class="orangelink"><strong>Update History</strong></td> </tr> <tr> <td width="108">Text</td> <td width="182"><label> <textarea name="history" cols="60" rows="12" class="fields" id="history"><?php echo $history; ?></textarea> </label></td> </tr> <tr> <td colspan="2"><label> <input name="Submit" type="submit" class="fields" id="Submit" value="Submit" /> </label></td> </tr> </table> </form> '; } else $content .= "You Must Be Logged In To Do That."; ?>
  9. Ok, I'm gonna suggest that instead of using explode to get the next ID of the file, I suggest you use $_GET to get it first? Use that again, and to determine the next image, you should SQL query the table to see the next ID you need to get. I'm gonna give an example... <?php // Let's say we use $_GET['id'] for the ID of the image. The URL would be [...]/img.php?id=7 for our example. $id = $_GET['id']; $result = mysql_query("SELECT * FROM `pictures` WHERE `picture_id` = '$id'"); // We'll use mysql_fetch_row to get the current image... $image = mysql_fetch_row($result); // Insert the code to fetch the code you want from the array // And as for the next and previous image... $next = mysql_query("SELECT `picture_id` FROM `pictures` WHERE `picture_id` > '$id' LIMIT 1"); // LIMIT 1 will tell it we only want to get 1 ID that is bigger than the current one (meaning, the next one will automatically be the next ID in the table) $nextlink = mysql_fetch_row($next); // Next link should link to pic.php?id=$nextlink[0] // Same for previous, only with the opposite comparison $prev = mysql_query("SELECT `picture_id` FROM `pictures` WHERE `picture_id` < '$id' LIMIT 1"); $prevlink = mysql_fetch_row($prev); // Link to $prevlink[0] ?> There's probably a better way to do this, but that's the best I can come up with right now =P sorry.
  10. Use if (strlen($array[value]) > 0) To determine if the field isn't empty. (Of course, replace $array with the array, and value with the value.)
  11. Add to the end of the script... print_r($_POST); And tell us what's the output.
  12. Ahhh *don't kill me* but I can't find the edit/modify button on the upper post. I forgot to mention, that no errors were generated.
  13. Hey there. Sorry to be asking this as my first post, but here goes, hope you manage to figure out what went on here. Basically I have a localhost website -- before I get a server I want a system properly running. Anyways, I have an image upload form which should resize an image and copy it to a further resized thumbnail. newphoto.template.php <?php print_r($_FILES); if (isset($_POST['photo'])) { $photo = image_resize($_FILES['photo']['tmp_name'], 800, 600); $thumb = image_resize($_FILES['photo']['tmp_name'], 160, 120); mysql_query("INSERT INTO `photos` (`poster_id`) VALUES ('".$_COOKIE['id']."')"); $result = mysql_query("SELECT `photo_id` FROM `photos` ORDER BY `photo_id` DESC LIMIT 1"); $photo_id = mysql_fetch_row($result); $size = getimagesize($_FILES['photo']['tmp_name']); switch ($size['mime']) { case 'image/jpeg': imagejpeg($photo, 'uploads/photos/photo_'.$photo_id[0].'.jpg'); imagejpeg($thumb, 'uploads/photos/thumbs/photo_'.$photo_id[0].'.jpg'); break; case 'image/png': imagepng($photo, 'uploads/photos/photo_'.$photo_id[0].'.png'); imagepng($thumb, 'uploads/photos/thumbs/photo_'.$photo_id[0].'.png'); break; } if (!$_POST['more']) { redirect('./?p=img&id='.$photo_id[0]); } } ?> <form action="?p=newphoto" method="post" enctype="multipart/form-data"> <input type="file" name="photo" /><br /> <input type="checkbox" checked="checked" name="more" />Upload another photo afterwards<br /> <input type="submit" value="Upload" /> </form> images.php <?php function image_resize($img_src, $new_w, $new_h) { $size = getimagesize($img_src); print_r($size); switch ($size['mime']) { case 'image/jpeg': $old = imgcreatefromjpeg($img_src); case 'image/png': $old = imgcreatefrompng($img_src); } $ratio = ($size[0] > $size[1]) ? $w / $new_w : $h / $new_h; echo $ratio; $w = $w / $ratio; $h = $h / $ratio; $img_dest = imagecreatetruecolor($w, $h); imagecopyresampled($img_dest, $old, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); return $img_dest; } ?> Basically what happens, is, nothing. No file is uploaded, no SQL insertion is done (which leads me to believe the problem is in the image_resize function?). I'm rather new to image manipulating, this is the first method I tried creating using one. It's supposed to return a resized (keeping ratio), copied image of the source image provided. Maybe I didn't get the hang of GD functions right? A few notes... [*]Both files are included in other template files, which have DB access, and other functions. [*]Ignore the fact I didn't validate correct file type, sizes, and if $_COOKIE['id'] actually exists, I'll do that once I'm sure everything works. If you need any further information just say so, thanks in advance!
×
×
  • 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.