Jump to content

Adastra

Members
  • Posts

    36
  • Joined

  • Last visited

    Never

Everything posted by Adastra

  1. I'm sending an e-mail via a contact form, but somehow the lines aren't breaking in the text, it always looks like this: lorem ipsum\r\n\r\dolor\r\n\r\n\r\sit\r\n\r\amet\r\n\r\n\r\lorem Which is of course not readable at all. What am I doing wrong here? I'm using a few security checks and such for cleaning the field up; $text = trim($text); ... $text = stripslashes(strip_tags($text)); ... $text = mysql_real_escape_string($text); ..... #and then the part where it's included in the message: $message .= "Nachricht: {$text} \n"; Can any of those be causing the display problem?
  2. Hi, I've written my own blog script, which works fine. The only thing that bothers me is that when someone posts a comment, the page is loaded at the top (beginning of the entry), instead of loading it at the same point where the user was before he hit "submit comment" (which is usually the commenting form). How can that be done? I currently use this for sending the person back to the entry page: header ("Location:". $_SERVER['HTTP_REFERER']);
  3. I need some quick help - I wanna run a UPDATE with a wildcard to mass edit the first part of an URL. What I've got in my database are things like http://myorldurl.net/images/myimage1.gif - with tons of different images or course. But what I wanna do is only change the  http://myorldurl.net to http://mynewurl.org. How do I do that? I've tried UPDATE table SET url="http://mynewurl.org/%" WHERE url="http://myorldurl.net/%", but unfortunately that didn't work :/ I know there is some other way to do that, which probably involves LEFT or RIGHT statement, but I'm pretty clueless right now. Thanks in advance!
  4. Yeah, of course... Anyway, it should also work even if the input box stays blank.
  5. Right now it's giving me this when I do the print_r Array ( [0] => [1] => )
  6. The file paths are fine, there's no problem with them...
  7. I have a small script to upload a previously chosen number of photos from 1-10 - but once I want to add the files (upload, resize and write database entries), I get this very very long site full of errors. I'm a PHP newbie, and I don't really know how to use the foreach and arrays and that stuff in this case. I've looked at the database after trying to post photos - it created a new row for each file I tried to upload, but it didn't enter any data, is just wrote the word "Array" into each fields (except the ID). So I assume that the information in the arrays is not correctly passed on... ?!? this is my code: [code] <?php include('config.php'); echo $header; if ($_POST['action'] == "add") { foreach ($_POST['title'] as $title) { //__ upload & resize _______________________________________ $ul_photo = $_FILES['photo']['tmp_name']; $src = imagecreatefromjpeg($ul_photo); list($width,$height) = getimagesize($ul_photo); $newwidth = 550; $newheight = ($height/$width)*$newwidth; $tmp = imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $filename = $dirpath.$gal_id."/". $_FILES['photo']['name']; imagejpeg($tmp,$filename,100); #__ thumb _________________________________________________________ $ul_thumb = $_FILES['photo']['tmp_name']; $srcthumb = imagecreatefromjpeg($ul_thumb); list($widththumb,$heightthumb) = getimagesize($ul_thumb); $newwidththumb = 100; $newheightthumb = ($heightthumb/$widththumb)*$newwidththumb; $src_top = ($src_height / 2) - ($dst_height / 2); $src_left = ($src_width / 2) - ($dst_width / 2); $tmpthumb = imagecreatetruecolor($newwidththumb,$newheightthumb); imagecopyresampled($tmpthumb,$srcthumb,0,0,$src_top,$src_left,$newwidththumb,$newheightthumb,$widththumb,$heightthumb); $thumbname = $dirpath.$gal_id."/zth_".$_FILES['photo']['name']; imagejpeg($tmpthumb,$thumbname,100); #___________________________________________________________________ imagedestroy($src); imagedestroy($tmp); imagedestroy($srcthumb); imagedestroy($tmpthumb); $gal = addslashes($_POST['gal_id']); $photo = $_FILES['photo']['name']; $title = addslashes($_POST['title']); $description = addslashes($_POST['description']); $sql = "INSERT INTO $gal_photos (gal,photo,title,description) VALUES ('$gal','$photo','$title','$description')"; $query = mysql_query($sql) or die("MySQL Error: <br /> {$sql} <br />". mysql_error()); $num = mysql_affected_rows(); if($num > 0) { echo "<span class='result'>New Photo successfully added!</span>"; echo "<br /><img src='../galleries/".$gal."/zth_".$photo."' />"; } else { echo "Error: ".mysql_error(); } } #foreach } elseif ($_GET['action'] == "listforms") { ?> <strong>Post New Photos</strong> <br /> <br /> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="649760" /> <? for ($x=0;$x<$_GET['num'];$x++) { ?> <div class='uploadbox'> Associated Gallery <?=$x + 1?>: <br /> <? $selgal_sql = "SELECT * FROM $gal_galleries ORDER BY id DESC"; $selgal_result = mysql_query($selgal_sql) or print ("Unable to select data.<br />".$selgal_sql."<br />".mysql_error()); $selgal_num = mysql_num_rows($selgal_result); if ($selgal_num > 0) { echo "<select name='gal_id[]'>"; while ($selgal_row = mysql_fetch_array($selgal_result)) { $selgal_id = $selgal_row["id"]; $selgal_title = $selgal_row["title"]; echo "<option value='".$selgal_id."'>".$selgal_id.": ".$selgal_title."</option>"; } echo "</select>"; } else { echo "<a href='gal_galleries.php'>Please create a new gallery to post photos!</a>"; } ?> <br /> <br /> Photo File <?=$x + 1?>: <br /> <input type='file' name='photo[]' size='50' /> <input type="hidden" name="thumb[]" value="<? ($_POST['photo']) ?>" /> <br /> <br /> <? if ($usetitle == "n")  { ?> <input type='hidden' name='title[]' value='' /> <? } else { ?> Photo Title <?=$x + 1?>: <br /> <input type='text' name='title[]' size='50' /> <br /> <br /> <? } ?> <? if ($usedesc == "n") { ?> <input type='hidden' name='description[]' value='' /> <? } else { ?> Photo Description <?=$x + 1?>: <br /> <textarea cols='45' rows='5' name='description[]'></textarea> <? } ?> </div> <br /> <? } ?> <br /> <br /> <input type="submit" name="action" value="add" /> </form> <? } else { ?> <strong>Post New Photos</strong> <br /> <br /> <form action="<?=$_SERVER['PHP_SELF']?>" method="get"> <input type="hidden" name="action" value="listforms" /> <label for="num">Select number of photos to post</label>: <select id="num" name="num"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> <input type="submit" value="Proceed" /> </form> <? } echo $footer; ?>[/code] these are my errors: [quote] Warning: imagecreatefromjpeg(Array) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /htdocs/gall/gal_postphotos.php on line 11 Warning: getimagesize(Array) [function.getimagesize]: failed to open stream: No such file or directory in /htdocs/gall/gal_postphotos.php on line 12 Warning: Division by zero in /htdocs/gall/gal_postphotos.php on line 14 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /htdocs/gall/gal_postphotos.php on line 15 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /htdocs/gall/gal_postphotos.php on line 16 Warning: imagejpeg(): supplied argument is not a valid Image resource in /htdocs/gall/gal_postphotos.php on line 18 Warning: imagecreatefromjpeg(Array) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /htdocs/gall/gal_postphotos.php on line 22 Warning: getimagesize(Array) [function.getimagesize]: failed to open stream: No such file or directory in /htdocs/gall/gal_postphotos.php on line 23 Warning: Division by zero in /htdocs/gall/gal_postphotos.php on line 25 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /htdocs/gall/gal_postphotos.php on line 30 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /htdocs/gall/gal_postphotos.php on line 31 Warning: imagejpeg(): supplied argument is not a valid Image resource in /htdocs/gall/gal_postphotos.php on line 33 Warning: imagedestroy(): supplied argument is not a valid Image resource in /htdocs/gall/gal_postphotos.php on line 36 Warning: imagedestroy(): supplied argument is not a valid Image resource in /htdocs/gall/gal_postphotos.php on line 37 Warning: imagedestroy(): supplied argument is not a valid Image resource in /htdocs/gall/gal_postphotos.php on line 38 Warning: imagedestroy(): supplied argument is not a valid Image resource in /htdocs/gall/gal_postphotos.php on line 39 [/quote]
  8. Can anyone help me fix that error please? I'm pretty much desperate...
  9. Cool, thanks a lot, but right now I get this incredibly long site of error messages when I try to post multiple photos...: I've looked in the Database, it created new entries for each, but it didn't insert anything except for the word "Array" in the first row. All other rows are blank (expect for the id of course). [quote] Warning: Division by zero in /www/htdocs/gallery/gal_postphotos2.php on line 15 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /www/htdocs/gallery/gal_postphotos2.php on line 16 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 17 Warning: imagejpeg(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 19 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 20 Warning: Division by zero in /www/htdocs/gallery/gal_postphotos2.php on line 26 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /www/htdocs/gallery/gal_postphotos2.php on line 29 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 30 Warning: imagejpeg(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 32 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 33 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 34 Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /www/htdocs/gallery/gal_postphotos2.php on line 41 Warning: Division by zero in /www/htdocs/gallery/gal_postphotos2.php on line 15 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /www/htdocs/gallery/gal_postphotos2.php on line 16 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 17 Warning: imagejpeg(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 19 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 20 Warning: Division by zero in /www/htdocs/gallery/gal_postphotos2.php on line 26 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /www/htdocs/gallery/gal_postphotos2.php on line 29 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 30 Warning: imagejpeg(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 32 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 33 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 34 Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /www/htdocs/gallery/gal_postphotos2.php on line 41 Warning: Division by zero in /www/htdocs/gallery/gal_postphotos2.php on line 15 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /www/htdocs/gallery/gal_postphotos2.php on line 16 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 17 Warning: imagejpeg(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 19 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 20 Warning: Division by zero in /www/htdocs/gallery/gal_postphotos2.php on line 26 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /www/htdocs/gallery/gal_postphotos2.php on line 29 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 30 Warning: imagejpeg(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 32 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 33 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 34 Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /www/htdocs/gallery/gal_postphotos2.php on line 41 Warning: Division by zero in /www/htdocs/gallery/gal_postphotos2.php on line 15 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /www/htdocs/gallery/gal_postphotos2.php on line 16 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 17 Warning: imagejpeg(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 19 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 20 Warning: Division by zero in /www/htdocs/gallery/gal_postphotos2.php on line 26 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /www/htdocs/gallery/gal_postphotos2.php on line 29 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 30 Warning: imagejpeg(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 32 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 33 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 34 Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /www/htdocs/gallery/gal_postphotos2.php on line 41 Warning: Division by zero in /www/htdocs/gallery/gal_postphotos2.php on line 15 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /www/htdocs/gallery/gal_postphotos2.php on line 16 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 17 Warning: imagejpeg(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 19 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 20 Warning: Division by zero in /www/htdocs/gallery/gal_postphotos2.php on line 26 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /www/htdocs/gallery/gal_postphotos2.php on line 29 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 30 Warning: imagejpeg(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 32 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 33 Warning: imagedestroy(): supplied argument is not a valid Image resource in /www/htdocs/gallery/gal_postphotos2.php on line 34 Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /www/htdocs/gallery/gal_postphotos2.php on line 41 [/quote]
  10. Hi guys, I'm trying to write a small gallery script which gives the possibility to upload a number of 1-10 files at once - first thing the user does is pick the number of files to upload, then he is directed to the upload form(s). Now my problem is that I don't know how to process the multiple files at once - there are 4 fields for each photo, the file itself, a title, a description and the gallery id. All of that is inserted into a DB after the images have been resized and uploaded - how do I do both of those things for multiple files at once? It must be something with for or foreach, but I have no idea how to use it with multiple files AND multiple fields to be post at once. The affected part is the add action. Any help would be very appreciated :) This is my file: [code=php:0] if ($_POST['action'] == "add") { foreach () { //__ photos in dir ablegen _______________________________________ $ul_photo = $_FILES['photo']['tmp_name']; $src = imagecreatefromjpeg($ul_photo); list($width,$height) = getimagesize($ul_photo); $newwidth = 550; $newheight = ($height/$width)*$newwidth; $tmp = imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $filename = $dirpath.$gal_id."/". $_FILES['photo']['name']; imagejpeg($tmp,$filename,100); #__ thumb _________________________________________________________ $ul_thumb = $_FILES['photo']['tmp_name']; $srcthumb = imagecreatefromjpeg($ul_thumb); list($widththumb,$heightthumb) = getimagesize($ul_thumb); $newwidththumb = 100; $newheightthumb = ($heightthumb/$widththumb)*$newwidththumb; $src_top = ($src_height / 2) - ($dst_height / 2); $src_left = ($src_width / 2) - ($dst_width / 2); $tmpthumb = imagecreatetruecolor($newwidththumb,$newheightthumb); imagecopyresampled($tmpthumb,$srcthumb,0,0,$src_top,$src_left,$newwidththumb,$newheightthumb,$widththumb,$heightthumb); $thumbname = $dirpath.$gal_id."/zth_".$titlesuf . $_FILES['photo']['name']; imagejpeg($tmpthumb,$thumbname,100); #___________________________________________________________________ imagedestroy($src); imagedestroy($tmp); imagedestroy($srcthumb); imagedestroy($tmpthumb); $gal = addslashes($_POST['gal_id']); $photo = $_FILES['photo']['name']; $title = addslashes($_POST['title']); $description = addslashes($_POST['description']); $sql = "INSERT INTO $gal_photos (gal,photo,title,description) VALUES ('$gal','$photo','$title','$description')"; $query = mysql_query($sql) or die("MySQL Error: <br /> {$sql} <br />". mysql_error()); $num = mysql_affected_rows(); if($num > 0) { echo "<span class='result'>New Photo successfully added!</span>"; echo "<br /><img src='../galleries/".$gal."/zth_".$photo."' />"; } else { echo "Error: ".mysql_error(); } } #foreach } elseif ($_GET['action'] == "listforms") { ?> <strong>Post New Photos</strong> <br /> <br /> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="649760" /> <? for ($x=0;$x<$_GET['num'];$x++) { ?> <div class='uploadbox'> Associated Gallery <?=$x + 1?>: <br /> <? $selgal_sql = "SELECT * FROM $gal_galleries ORDER BY id DESC"; $selgal_result = mysql_query($selgal_sql) or print ("Unable to select data.<br />".$selgal_sql."<br />".mysql_error()); $selgal_num = mysql_num_rows($selgal_result); if ($selgal_num > 0) { echo "<select name='gal_id[]'>"; while ($selgal_row = mysql_fetch_array($selgal_result)) { $selgal_id = $selgal_row["id"]; $selgal_title = $selgal_row["title"]; echo "<option value='".$selgal_id."'>".$selgal_id.": ".$selgal_title."</option>"; } echo "</select>"; } else { echo "<a href='gal_galleries.php'>Please create a new gallery to post photos!</a>"; } ?> <br /> <br /> Photo File <?=$x + 1?>: <br /> <input type='file' name='photo[]' size='50' /> <input type="hidden" name="thumb[]" value="<? ($_POST['photo']) ?>" /> <br /> <br /> Photo Title <?=$x + 1?>: <br /> <input type='text' name='title[]' size='50' /> <br /> <br /> Photo Description <?=$x + 1?>: <br /> <textarea cols='45' rows='5' name='description[]'></textarea> </div> <br /> <?php } ?> <br /> <br /> <input type="submit" name="action" value="add" /> </form> <? } else { ?> <strong>Post New Photos</strong> <br /> <br /> <form action="<?=$_SERVER['PHP_SELF']?>" method="get"> <input type="hidden" name="action" value="listforms" /> <label for="num">Select number of photos to post</label>: <select id="num" name="num"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> <input type="submit" value="Proceed" /> </form> <? } [/code]
  11. Hi guys, I'm trying to write a small gallery script which gives the possibility to upload a number of 1-10 files at once - first thing the user does is pick the number of files to upload, then he is directed to the upload form(s). Now my problem is that I don't know how to process the multiple files at once - there are 4 fields for each photo, the file itself, a title, a description and the gallery id. All of that is inserted into a DB after the images have been resized and uploaded - how do I do both of those things for multiple files at once? It must be something with for or foreach, but I have no idea how to use it with multiple files AND multiple fields to be post at once. The affected part is the add action. Any help would be very appreciated :) This is my file: [code=php:0] if ($_POST['action'] == "add") { foreach () { //__ photos in dir ablegen _______________________________________ $ul_photo = $_FILES['photo']['tmp_name']; $src = imagecreatefromjpeg($ul_photo); list($width,$height) = getimagesize($ul_photo); $newwidth = 550; $newheight = ($height/$width)*$newwidth; $tmp = imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $filename = $dirpath.$gal_id."/". $_FILES['photo']['name']; imagejpeg($tmp,$filename,100); #__ thumb _________________________________________________________ $ul_thumb = $_FILES['photo']['tmp_name']; $srcthumb = imagecreatefromjpeg($ul_thumb); list($widththumb,$heightthumb) = getimagesize($ul_thumb); $newwidththumb = 100; $newheightthumb = ($heightthumb/$widththumb)*$newwidththumb; $src_top = ($src_height / 2) - ($dst_height / 2); $src_left = ($src_width / 2) - ($dst_width / 2); $tmpthumb = imagecreatetruecolor($newwidththumb,$newheightthumb); imagecopyresampled($tmpthumb,$srcthumb,0,0,$src_top,$src_left,$newwidththumb,$newheightthumb,$widththumb,$heightthumb); $thumbname = $dirpath.$gal_id."/zth_".$titlesuf . $_FILES['photo']['name']; imagejpeg($tmpthumb,$thumbname,100); #___________________________________________________________________ imagedestroy($src); imagedestroy($tmp); imagedestroy($srcthumb); imagedestroy($tmpthumb); $gal = addslashes($_POST['gal_id']); $photo = $_FILES['photo']['name']; $title = addslashes($_POST['title']); $description = addslashes($_POST['description']); $sql = "INSERT INTO $gal_photos (gal,photo,title,description) VALUES ('$gal','$photo','$title','$description')"; $query = mysql_query($sql) or die("MySQL Error: <br /> {$sql} <br />". mysql_error()); $num = mysql_affected_rows(); if($num > 0) { echo "<span class='result'>New Photo successfully added!</span>"; echo "<br /><img src='../galleries/".$gal."/zth_".$photo."' />"; } else { echo "Error: ".mysql_error(); } } #foreach } elseif ($_GET['action'] == "listforms") { ?> <strong>Post New Photos</strong> <br /> <br /> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="649760" /> <? for ($x=0;$x<$_GET['num'];$x++) { ?> <div class='uploadbox'> Associated Gallery <?=$x + 1?>: <br /> <? $selgal_sql = "SELECT * FROM $gal_galleries ORDER BY id DESC"; $selgal_result = mysql_query($selgal_sql) or print ("Unable to select data.<br />".$selgal_sql."<br />".mysql_error()); $selgal_num = mysql_num_rows($selgal_result); if ($selgal_num > 0) { echo "<select name='gal_id[]'>"; while ($selgal_row = mysql_fetch_array($selgal_result)) { $selgal_id = $selgal_row["id"]; $selgal_title = $selgal_row["title"]; echo "<option value='".$selgal_id."'>".$selgal_id.": ".$selgal_title."</option>"; } echo "</select>"; } else { echo "<a href='gal_galleries.php'>Please create a new gallery to post photos!</a>"; } ?> <br /> <br /> Photo File <?=$x + 1?>: <br /> <input type='file' name='photo[]' size='50' /> <input type="hidden" name="thumb[]" value="<? ($_POST['photo']) ?>" /> <br /> <br /> Photo Title <?=$x + 1?>: <br /> <input type='text' name='title[]' size='50' /> <br /> <br /> Photo Description <?=$x + 1?>: <br /> <textarea cols='45' rows='5' name='description[]'></textarea> </div> <br /> <?php } ?> <br /> <br /> <input type="submit" name="action" value="add" /> </form> <? } else { ?> <strong>Post New Photos</strong> <br /> <br /> <form action="<?=$_SERVER['PHP_SELF']?>" method="get"> <input type="hidden" name="action" value="listforms" /> <label for="num">Select number of photos to post</label>: <select id="num" name="num"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> <input type="submit" value="Proceed" /> </form> <? } [/code]
  12. thanks blear, that was the error. I don't understand though why it didn't pass the id on, I've defined it in the part which is in front of the first if {} ....
  13. thanks, I tried that snippet, but I still have the same problem: it doesn't do anything :( I don't understand why it's not updating - the selecting and everything else works without a problem...
  14. I have this tiny tiny updated script, but for some reason it's not updating the data in the database. I don't even get an error, all it does is give me the message "Gallery blah has been updated", but it still didn't update anything in the database. And I absolutely can't see what's wrong with my query. Can anyone help me find the error please? :) [code=php:0] <?php require_once('gal_confi.php'); echo $header; $id = $_GET['id']; if ($_GET['action'] == "") { $result = mysql_query ("SELECT * FROM $gal_galleries WHERE id='$id'") or print ("Unable to select data.<br />".mysql_error()); while ($row = mysql_fetch_array($result)) { $date = date("M dS, Y",$row["timestamp"]); $timestamp = $row["timestamp"]; $old_title = $row["title"]; $old_description = $row["description"]; $old_title = str_replace('"','\'',$old_title); $old_description = str_replace('"','\'',$old_description); } echo "<strong>Edit Gallery # ".$id.", created on ".$date."</strong><br /><br />"; ?> <form method="post" action="gal_galleries_update.php?action=submit"> Gallery Title: <br /> <input type="text" size="70" name="title" id="title" value="<? echo $old_title; ?>" /> <br /> <br /> Gallery Description: <br /> <textarea cols="65" rows="10" name="description" id="description"><? echo $old_description; ?></textarea> <br /> <input type="submit" name="submit" value="submit"> </form> <?php } elseif (isset($_GET['action']) && ($_GET['action'] == "submit")) { $id = $_GET['id']; $title = addslashes($_POST['title']); $description = addslashes($_POST['description']); $result = mysql_query("UPDATE $gal_galleries SET title='$title',description='$description' WHERE id='$id'") or print ("Unable to post data.<br />".mysql_error()); if ($result != false) { print "Gallery <strong>$title</strong> has been updated!"; } else { mysql_error(); } } print "<br /><br />Back to <a href='index.php'>GalAdmy</a>."; echo $footer; ?> [/code]
  15. I know there's some way this will work out, I just need to know how to extract the month from a timestamp first. I attempted something like this, but it didn't return any results. (I'm a PHP noob, I only have a vague idea of what I'm doing). [code]$bday_today_month = date("F"); $bday_today_monthm = date("m"); $bday_today_year = date("Y"); $months = array(01,02,03,04,05,06,07,08,09,10,11,12); foreach ($months as $month) { $months_sql = "SELECT * FROM $bday_table WHERE timestamp = month($month) ORDER BY timestamp"; $months_result = mysql_query($months_sql) or print ("Unable to select data.<br />" . $months_sql . "<br />" . mysql_error()); while ($months_row = mysql_fetch_array($months_result)) { $months_date = date("M",$months_row["timestamp"]); echo $months_date ; $bday_sql = "SELECT * FROM $bday_table FROM_UNIXTIME(timestamp,'%M') = $month ORDER BY timestamp"; $bday_result = mysql_query($bday_sql) or print ("Unable to select data.<br />" . $bday_sql . "<br />" . mysql_error()); while ($bday_row = mysql_fetch_array($bday_result)) { $bday_date = date("M d, Y",$bday_row["timestamp"]); $bday_name = $bday_row["name"]; $bday_email = $bday_row["email"]; $bday_url = $bday_row["url"]; $bday_year = date("Y",$bday_row["timestamp"]); $bday_age = ($bday_today_year - $bday_year); echo $bday_date." - ".$bday_name." (".$bday_age.")<br />"; } } }[/code]
  16. [quote author=redarrow link=topic=106369.msg425337#msg425337 date=1157030019] DESC or ASC look them up.// For your select issue. also look up date on  php.net // That to display the months. [/quote] I know how to use DESC, ASC and date. My problem is that I don't know how to sort by [b]month[/b] with the timestamp instead of sorting by year (=timestamp).... :/
  17. It works perfectly fine with people born before 1970 - the timestamps of those are with a minus in front. I haven't had any problems with that so far....
  18. I made a tiny birthday calendar for private use, which uses a timestamp for the birthday. So far it works fine, but since I'm a PHP noob, I have two problems: 1) How can I do a select sorted by month? Right now, when I select with ORDER BY timestamp, it gives me the oldest person first and the youngest last, means it's sorted by year. 2) How can I have it automatically sorting it by month with the month as headline? Like this example: January 01/11/75 - Jane Doe (31) 01/21/80 - Janette Doe (26) February 02/02/79 - Peter Parker (27) 02/18/44 - Clark Kent (62) ...and so on My current code looks like this. [code] include('connect'); $bday_table = "mytable"; $bday_today_month = date("F"); $bday_today_monthm = date("m"); $bday_today_year = date("Y"); $bday_sql = "SELECT * FROM $bday_table ORDER BY timestamp"; $bday_result = mysql_query($bday_sql) or print ("Unable to select data.<br />" . $bday_sql . "<br />" . mysql_error()); while ($bday_row = mysql_fetch_array($bday_result)) { $bday_date = date("M d, Y",$bday_row["timestamp"]); $bday_name = $bday_row["name"]; $bday_email = $bday_row["email"]; $bday_url = $bday_row["url"]; $bday_year = date("Y",$bday_row["timestamp"]); $bday_age = ($bday_today_year - $bday_year); echo $bday_date." - ".$bday_name." (".$bday_age.")<br />"; }[/code] I'd be grateful for any help, snippets & stuff like that ;)
  19. Anyone else have any ideas? I'm sure it's something in the form or before the uploading happens. I'm so bad at spotting errors, especially because I'm still a noob :/
  20. Mhmm thanks, but I don't really think thats the problem, because it works with the same code in my "post new entry" form. It just doesn't work in this editing form... (?_?)
  21. Hi folks, I have a form for updating an entry in a database, which is pretty much the same as my form for posting into the database, with the difference that this one isn't working. Can anyone help me find out what's wrong? I don't get an error, I just get a blank page when I try to update something. The error has to have something to do with the upload, because even if I don't upload something new, the updating doesn't work (like when I only want to change text). The upload stuff is a little messy but it's all for private use only. It posts an image and creates a resized copy as well. I'm still a noob, so try to explain for dummies & show me exactly what to change ;) [code=php:0] <? if ($_GET['action'] == "") { $table = "mytable"; include('connect.php'); $result = mysql_query ("SELECT * FROM $table WHERE id='$id'") or print ("Can't select entry.<br />" . $sql . "<br />" . mysql_error()); while ($row = mysql_fetch_array($result)) { $id = $row["id"]; $old_timestamp = $row["timestamp"]; $old_draft = $row["draft"]; $old_title = $row["title"]; $old_title = str_replace('"','\'',$old_title); $old_media = $row["media"]; $old_movyear = $row["year"]; $old_rate = $row["rate"]; $old_reviewimg = $row["reviewimg"]; $old_photo1 = $row["photo1"]; $old_photo2 = $row["photo2"]; $old_photo3 = $row["photo3"]; $old_entry = $row["entry"]; $old_month = date("F",$old_timestamp); $old_date = date("d",$old_timestamp); $old_year = date("Y",$old_timestamp); $old_time = date("H:i",$old_timestamp); } ?> <form method="post" action="update.php?action=submit" enctype="multipart/form-data"> <input type="hidden" name="id" value="<? echo $id ?>"> <b>Date:</b> <select name="month"> <option value="<? echo $old_month ?>"><? echo $old_month ?></option> <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <input type="text" name="date" size="2" value="<? echo $old_date ?>"> <select name="year"> <option value="<? echo $old_year ?>"><? echo $old_year ?></option> <option value="2006">2006</option> <option value="2007">2007</option> <option value="2008">2008</option> <option value="2009">2008</option> <option value="2010">2010</option> <option value="2010">2011</option> <option value="2010">2012</option> <option value="2010">2013</option> <option value="2010">2014</option> <option value="2010">2015</option> <option value="2010">2016</option> </select> <input type="text" name="time" size="5" value="<? echo $old_time ?>"> <b>Draft:</b> <select name="draft"> <option value="<? echo $old_draft ?>"><? echo $old_draft ?></option> <option value="no">no</option> <option value="yes">yes</option> </select> <br /> <br /> <b>Title:</b> <br /> <input type="text" name="title" size="60" value="<? echo $old_title ?>" /> <br /> <br /> <b>Rating:</b> <br /> <select name="rate"> <option value="<? echo $old_rate ?>"><? echo $old_rate ?></option> <option value="rate00">0.0 | 00% - 09%</option> <option value="rate05">0.5 | 10% - 19%</option> <option value="rate10">1.0 | 20% - 29%</option> <option value="rate15">1.5 | 30% - 35%</option> <option value="rate20">2.0 | 36% - 43%</option> <option value="rate25">2.5 | 44% - 51%</option> <option value="rate30">3.0 | 52% - 60%</option> <option value="rate35">3.5 | 61% - 69%</option> <option value="rate40">4.0 | 70% - 78%</option> <option value="rate45">4.5 | 79% - 84%</option> <option value="rate50">5.0 | 85% - 91%</option> <option value="rate55">5.5 | 92% - 96%</option> <option value="rate60">6.0 | 97% - 100%</option> </select> <br /> <br /> <table cellpadding="0" cellspacing="0"> <tr> <td> <b>Image:</b> <br /> <? if ($old_reviewimg == "") { echo "<input type='file' name='reviewimg' size='60' />"; } else { echo "<input type='text' name='reviewimg' size='60' value='$old_reviewimg' />"; } ?> </td> <td> <? if ($old_reviewimg != "") { echo "<img src='images/$old_reviewimg' height='50' />"; } ?> </td> </tr> </table> <table cellpadding="0" cellspacing="0"> <tr> <td> <b>Photo 1:</b> <br /> <? if ($old_photo1 == "") { echo "<input type='file' name='photo1' size='60' />"; } else { echo "<input type='text' name='photo1' size='60' value='$old_photo1' />"; } ?> </td> <td> <? if ($old_photo1 != "") { echo "<img src='images/small_$old_photo1' height='50' />"; } ?> </td> </tr> </table> <table cellpadding="0" cellspacing="0"> <tr> <td> <b>Photo 2:</b> <br /> <? if ($old_photo2 == "") { echo "<input type='file' name='photo2' size='60' />"; } else { echo "<input type='text' name='photo2' size='60' value='$old_photo2' />"; } ?> </td> <td> <? if ($old_photo2 != "") { echo "<img src='images/small_$old_photo2' height='50' />"; } ?> </td> </tr> </table> <table cellpadding="0" cellspacing="0"> <tr> <td> <b>Photo 3:</b> <br /> <? if ($old_photo3 == "") { echo "<input type='file' name='photo3' size='60' />"; } else { echo "<input type='text' name='photo3' size='60' value='$old_photo3' />"; } ?> </td> <td> <? if ($old_photo3 != "") { echo "<img src='images/small_$old_photo3' height='50' />"; } ?> </td> </tr> </table> <br /> <textarea cols="80" rows="30" name="entry"><? echo $old_entry ?></textarea> <br /> <input type="submit" name="submit" value="submit"> </form> <? } elseif (isset($_GET['action']) && $_GET['action'] == "submit") { if ($reviewimg != "") { $reviewimg = $_FILES['reviewimg']['name']; $tmp_name = $_FILES['reviewimg']['tmp_name']; if (!isset($reviewimg)) { exit; } if(!is_uploaded_file($tmp_name)) { echo "Fehler!"; switch ($_FILES['cover']['error']) { case 1: echo "Zu groß"; break; case 2: echo "Zu groß"; break; case 3: echo "Nur tw übertragen"; break; case 4: echo "Keine Datei angegeben"; break; } exit; } $uploadname ="/www/htdocs/images/$reviewimg"; move_uploaded_file($tmp_name, $uploadname); } //__ photo1 ___________________________________ if ($photo1 != "") { $uploadedphoto1 = $_FILES['photo1']['tmp_name']; $src1 = imagecreatefromjpeg($uploadedphoto1); list($width1,$height1) = getimagesize($uploadedphoto1); $newwidth1 = 460; $newheight1 = 346; $tmp1 = imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp1,$src1,0,0,0,0,$newwidth1,$newheight1,$width1,$height1); $filename1 = "/www/htdocs/images/". $_FILES['photo1']['name']; imagejpeg($tmp1,$filename1,100); #__ thumb _________________________________________________________ $uploadedthumb1 = $_FILES['photo1']['tmp_name']; $srcthumb1 = imagecreatefromjpeg($uploadedthumb1); list($widththumb1,$heightthumb1) = getimagesize($uploadedthumb1); $newwidththumb1 = 140; $newheightthumb1 = 105; $src_top1 = ($src_height1 / 2) - ($dst_height1 / 2); $src_left1 = ($src_width1 / 2) - ($dst_width1 / 2); $tmpthumb1 = imagecreatetruecolor($newwidththumb1,$newheightthumb1); imagecopyresampled($tmpthumb1,$srcthumb1,0,0,$src_top1,$src_left1,$newwidththumb1,$newheightthumb1,$widththumb1,$heightthumb1); $thumbname1 = "/www/htdocs/images/small_". $_FILES['photo1']['name']; imagejpeg($tmpthumb1,$thumbname1,100); #___________________________________________________________________ imagedestroy($srcthumb1); imagedestroy($tmpthumb1); imagedestroy($src1); imagedestroy($tmp1); $photo1 =  $_FILES['photo1']['name']; $thumb1 = "small_". $_FILES['photo1']['name']; } //__ photo2 ___________________________________ if ($photo2 != "") { $uploadedphoto2 = $_FILES['photo2']['tmp_name']; $src2 = imagecreatefromjpeg($uploadedphoto2); list($width2,$height2) = getimagesize($uploadedphoto2); $newwidth2 = 460; $newheight2 = 346; $tmp2 = imagecreatetruecolor($newwidth2,$newheight2); imagecopyresampled($tmp2,$src2,0,0,0,0,$newwidth2,$newheight2,$width2,$height2); $filename2 = "/www/htdocs/images/". $_FILES['photo2']['name']; imagejpeg($tmp2,$filename2,100); #__ thumb _________________________________________________________ $uploadedthumb2 = $_FILES['photo2']['tmp_name']; $srcthumb2 = imagecreatefromjpeg($uploadedthumb2); list($widththumb2,$heightthumb2) = getimagesize($uploadedthumb2); $newwidththumb2 = 140; $newheightthumb2 = 105; $src_top2 = ($src_height2 / 2) - ($dst_height2 / 2); $src_left2 = ($src_width2 / 2) - ($dst_width2 / 2); $tmpthumb2 = imagecreatetruecolor($newwidththumb2,$newheightthumb2); imagecopyresampled($tmpthumb2,$srcthumb2,0,0,$src_top2,$src_left2,$newwidththumb2,$newheightthumb2,$widththumb2,$heightthumb2); $thumbname2 = "/www/htdocs/images/small_". $_FILES['photo2']['name']; imagejpeg($tmpthumb2,$thumbname2,100); #___________________________________________________________________ imagedestroy($srcthumb2); imagedestroy($tmpthumb2); imagedestroy($src2); imagedestroy($tmp2); $photo2 =  $_FILES['photo2']['name']; $thumb2 = "small_". $_FILES['photo2']['name']; } //__ photo3 ___________________________________ if (($old_photo3 == "") && ($photo3 != "")) { $uploadedphoto3 = $_FILES['photo3']['tmp_name']; $src3 = imagecreatefromjpeg($uploadedphoto3); list($width3,$height3) = getimagesize($uploadedphoto3); $newwidth3 = 460; $newheight3 = 346; $tmp3 = imagecreatetruecolor($newwidth3,$newheight3); imagecopyresampled($tmp3,$src3,0,0,0,0,$newwidth3,$newheight3,$width3,$height3); $filename3 = "/www/htdocs/images/". $_FILES['photo3']['name']; imagejpeg($tmp3,$filename3,100); #__ thumb _________________________________________________________ $uploadedthumb3 = $_FILES['photo3']['tmp_name']; $srcthumb3 = imagecreatefromjpeg($uploadedthumb3); list($widththumb3,$heightthumb3) = getimagesize($uploadedthumb3); $newwidththumb3 = 140; $newheightthumb3 = 105; $src_top3 = ($src_height3 / 2) - ($dst_height3 / 2); $src_left3 = ($src_width3 / 2) - ($dst_width3 / 2); $tmpthumb3 = imagecreatetruecolor($newwidththumb3,$newheightthumb3); imagecopyresampled($tmpthumb3,$srcthumb3,0,0,$src_top3,$src_left3,$newwidththumb3,$newheightthumb3,$widththumb3,$heightthumb3); $thumbname3 = "/www/htdocs/images/small_". $_FILES['photo3']['name']; imagejpeg($tmpthumb3,$thumbname3,100); #___________________________________________________________________ imagedestroy($srcthumb3); imagedestroy($tmpthumb3); imagedestroy($src3); imagedestroy($tmp3); $photo3 =  $_FILES['photo3']['name']; $thumb3 = "small_". $_FILES['photo3']['name']; } $month = htmlspecialchars(strip_tags($_POST['month'])); $date = htmlspecialchars(strip_tags($_POST['date'])); $year = htmlspecialchars(strip_tags($_POST['year'])); $time = htmlspecialchars(strip_tags($_POST['time'])); $timestamp = strtotime($month . " " . $date . " " . $year . " " . $time); $id = $_POST['id']; $title = htmlspecialchars(addslashes($_POST['title'])); $draft = htmlspecialchars(addslashes($_POST['draft'])); $movyear = addslashes($_POST['movyear']); $rate = addslashes($_POST['rate']); $entry = addslashes($_POST['entry']); include('connect.php'); $result = mysql_query("UPDATE $table SET timestamp='$timestamp', title='$title', draft='$draft', year='$movyear', rate='$rate', reviewimg='$reviewimg', photo1='$photo1', photo2='$photo2', photo3='$photo3', entry='$entry' WHERE id='$id'") or print ("Can't update entry.<br />" . $sql . "<br />" . mysql_error()); if ($result != false) { print "<strong>$title</strong> has been updated!"; } mysql_close(); } ?> [/code] Thanks in advance :)
  22. Hmmpf, it's not working, I get this error (multiple times): Warning: main(): Failed opening '/var/www/index.php?p=page3' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/unisys-outsourcing/index.php on line 5
×
×
  • 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.