Jump to content

jameschambers

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jameschambers's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm trying to write a script that will rename a video uploaded into a form then move it into a folder, but it won't recognise the file type. I have been uploading a file with a .mpg extenstion to test it but all i am getting is [b]'invalid video format: video/x-mpeg'[/b] I looked up mpeg/mpe/mpg file formats and as far as i can tell it should be ok. Here is the relevant code: [i] from video.php[/i] <form action="video_submit.php" method="post" enctype="multipart/form-data"> <input type="file" name="video" class="upload" size="40"> <input type="submit" value="Update Project" class="updatebutton"> </form> [i]from video_submit.php[/i] if ( (isset($_FILES['video']['name']) && is_uploaded_file($_FILES['video']['tmp_name']))) { if (!isset($_REQUEST['story']) || $_REQUEST['story']=='') { $story = mysqli_insert_id($handle); } $type = basename($_FILES['video']['type']); switch ($type) { case 'mpg': case 'mpeg': case 'mpe': $filename = "video/$story.mpg"; move_uploaded_file($_FILES['video']['tmp_name'], '../'.$filename); $query = "update stories set video = '$filename' where id = $story"; $result = $handle->query($query); break; case 'avi': case 'vfw': case 'avx': $filename = "video/$story.avi"; move_uploaded_file($_FILES['video']['tmp_name'], '../'.$filename); $query = "update stories set picture = '$filename' where id = $story"; $result = $handle->query($query); break; default: echo 'Invalid video format: '. $_FILES['video']['type']; } } Any help gratefully received.
  2. I'm trying to write a script that will delete an image from my database but am not having much luck. I basically want the user to be able to select the image(s) they want to delete from the checkbox then submit the form which goes to the script that deletes them. Here is the form: <form action="delete_image.php" method="post" enctype="multipart/form-data"> <input type="hidden" name="story" value="<?php echo $_REQUEST['story'];?>"> <input type="checkbox" name="imageone" value="<?php echo $_REQUEST['imageone'];?>"> Delete image one<br /> <input type="checkbox" name="imagetwo" value="<?php echo $_REQUEST['imagetwo'];?>"> Delete image two<br /> <input type="submit" value="Delete Selected"> </form> And here is the delete_image.php <?php include_once('include_fns.php'); $handle = db_connect(); $story = $_REQUEST['story']; $imageone = $_REQUEST['imageone']; $imagetwo = $_REQUEST['imagetwo']; if(check_permission($_SESSION['auth_user'], $story)) if (isset($imageone)) { $query = "delete picture from stories where id = $story"; $result = $handle->query($query); } if (isset($imagetwo)) { $query = "delete picture2 from stories where id = $story"; $result = $handle->query($query); } header('Location: '.$_SERVER['HTTP_REFERER']); ?> Thanks in advance
  3. Thanks very much, thats done the trick.
  4. Hi, got a follow up question about the script, I would like it to be able to resize gifs and pngs as well as jpegs, i'm sure there is a very straight forward way to do this but being pretty new to php i can't seem to get it to work. Cheers
  5. Thanks, still a bit faded but much better. Cheers!
  6. I am using a jpeg image resizing script which is destroying the colour of the images I am putting into it. The best way i can describe them is washed out, althogh sometimes they come out totally monochrome. Is this a bug? what can I do to stop it? Any help gratefully received <?php $image = $_REQUEST['image']; $max_width = $_REQUEST['max_width']; $max_height = $_REQUEST['max_height']; if (!$max_width) $max_width = 80; if (!$max_height) $max_height = 60; $size = GetImageSize($image); $width = $size[0]; $height = $size[1]; $x_ratio = $max_width / $width; $y_ratio = $max_height / $height; if ( ($width <= $max_width) && ($height <= $max_height) ) { $tn_width = $width; $tn_height = $height; } else if (($x_ratio * $height) < $max_height) { $tn_height = ceil($x_ratio * $height); $tn_width = $max_width; } else { $tn_width = ceil($y_ratio * $width); $tn_height = $max_height; } $src = ImageCreateFromJpeg($image); $dst = ImageCreate($tn_width,$tn_height); ImageCopyResized($dst, $src, 0, 0, 0, 0, $tn_width,$tn_height,$width,$height); header('Content-type: image'); ImageJpeg($dst, null, -1); ImageDestroy($src); ImageDestroy($dst); ?>
  7. Hi As I'm sure you will be able to tell, I'm very new to this whole php thing. I'm basically trying to set up a really simple CMS, one in which a list of topic titles is displayed in an a menu on the left, then when you click on the title it brings up the whole 'article'. The code here is code taken from an existing cms and modified, but as i say i'm pretty new to this and have come to a bit of a dead end. the header.php is included on every page, and is the 'menu' part of it. the page.php is the script i want to display the individual articles. I know i need to pass the ID for the specific article to the page.php but am at a bit of a loss as to how to do it. Very grateful for any help [b]header.php[/b] <?php if (!isset($_REQUEST['page'])&&!isset($_REQUEST['story'])) $page = 'news'; $story = intval($_REQUEST['story']); include_once('db_fns.php'); $handle = db_connect(); if($story) { $query = "select * from stories where id = '$story' and published is not null"; } else { $query = "select * from stories where page = '$page' and published is not null order by published desc"; } $result = $handle->query($query); while ($story = $result->fetch_assoc()) { // headline echo "<ul id='homemenu'>"; echo "<li><a href='page.php?id=$story'>{$story['headline']}</a></li>"; echo "</ul>"; } ?> [b]page.php[/b] <?php if (!isset($_REQUEST['page'])&&!isset($_REQUEST['story'])) { header('Location: index.php'); exit; } $page = ($_REQUEST['page']); $story = intval($_REQUEST['story']); include_once('db_fns.php'); include_once('header.php'); $handle = db_connect(); if($story) { $query = "select * from stories where id = '$story' and published is not null"; } else { $query = "select * from stories where page = '$page' and published is not null order by published desc"; } $result = $handle->query($query); while ($story = $result->fetch_assoc()) { // headline echo "<div id='contentouter'>"; echo "<h2>{$story['headline']}</h2>"; //picture if ($story['picture']) { echo '<div style="float:right; margin:0px 0px 6px 6px;">'; echo '<img src="resize_image.php?image='; echo urlencode($story[picture]); echo '&max_width=900&max_height=900" align = right/></div>'; } // byline $w = get_writer_record($story['writer']); echo '<br /><p class="byline">'; echo $w[full_name].', '; echo date('M d, H:i', $story['modified']); echo '</p>'; // main text echo $story['story_text']; } echo "</div>"; ?>
  8. I'm working on a basic CMS as covered in the book PHP and MySQL Web Development by Luke Welling and Laura Thomson, hoping to adapt it to what I need. But when I uploaded the code (it was inlcuded with the book on CD) and went to index.php I got the error; Call to a member function on a non-object in /directory/index.php/ on line 8 As I guess the code they supplied with the book is fine I'm assuming it's something to do with the server set up. It is running PHP Version 4.4.1. Any help much appreciated Cheers
×
×
  • 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.