Jump to content

Adastra

Members
  • Posts

    36
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Adastra's Achievements

Member

Member (2/5)

0

Reputation

  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...
×
×
  • 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.