Jump to content

justAnoob

Members
  • Posts

    561
  • Joined

  • Last visited

    Never

Everything posted by justAnoob

  1. Could I just use UPDATE instead of INSERT? I'll be back in a bit. I want to try a few things.
  2. So then I can't insert something into a row with a specific id?(the id changes depending what picture they are viewing.)
  3. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = '2'' at line 1
  4. Sorry,, I have lots of questions..... I get a syntax error,, why?,,, everthing looks right. <?php mysql_query("INSERT INTO abcxyz(imgpath2)VALUES('$imgpath')WHERE id = '$idnumber'") or die(mysql_error()); ?>
  5. I figured it out,, should of hit solved button.
  6. How do you properly code this line? <?php $item_id_catch = ($_POST[ . $row['id'] . ]); ?>
  7. I have it at the top of the page,, I just put it there to show that I'm using session start.
  8. you can add "pjpeg" if you want. the four that I allow to upload are jpg jpeg png bmp
  9. I try to pass the variable to another page.. but it does not work.. check out the commented line. <form id="form2" name="form2" method="post" action="updatetrade.php"> <?php session_start(); include "connection.php"; if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } $findit = $_SESSION['id']; $result = mysql_query("SELECT id FROM members WHERE username = '$findit' LIMIT 1"); $e_row = mysql_fetch_assoc($result); $query = mysql_query("SELECT count(*) FROM abcxyz WHERE user_id = " . $e_row['id']) or die(mysql_error()); $query_data = mysql_fetch_row($query); $numrows = $query_data[0]; $rows_per_page = 1; $lastpage = ceil($numrows/$rows_per_page); $pageno = (int)$pageno; $prevpage = $pageno-1; $nextpage = $pageno+1; if ($pageno > $lastpage) { $pageno = $lastpage; } if ($pageno < 1) { $pageno = 1; } $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; $sql = mysql_query("SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = " . $e_row['id'] . " $limit"); if($lastpage != 0) { echo "<table width='954' border='0' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#BBD4E1'>"; while ($row = mysql_fetch_array($sql)) { echo "<tr><td width='188' height='180'><div align='center'>"; echo '<img src="' . $row['imgpath'] . '" width="125" alt="" />'; echo "</div></td><td width='188'><div align='center'>"; if(empty($row['imgpath2'])) { echo '<a href="picture2.php">Click to Upload Picture #2.</a>'; } else { echo '<img src="' . $row['imgpath2'] . '" width="125" alt="" />'; } echo "</div></td><td width='188'><div align='center'>"; echo '<img src="' . $row['imgpath3'] . '" width="125" alt="" />'; echo "</div></td><td width='188'><div align='center'>"; echo '<img src="' . $row['imgpath4'] . '" width="125" alt="" />'; echo "</div></td><td width='190'><div align='center'>"; echo '<img src="' . $row['imgpath5'] . '" width="125" alt="" />'; echo "</div></td></tr><tr><td height='43' colspan='4'>"; echo '<strong>Item Name:</strong> <input type="text" name="item_name" value="' . $row['item_name'] . '" size="50" /> '; if ($pageno == 1) { echo " Previous Item "; } else { echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'> Previous Item </a>"; } echo "($pageno of $lastpage)"; if ( $pageno == $lastpage ) { echo " Next Item "; } else { echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'> Next Item </a>"; } echo "</td><td><div align='center'>"; echo '<input type="hidden" name="id" value="' . $row['id'] . '" size="25" />'; echo "</div></td></tr><tr><td height='116' colspan='4'>"; echo '<strong>Description:</strong> <textarea name="description" cols="75" rows="5">' . $row['description'] . '</textarea>'; echo "</td><td><div align='center'>"; echo '<input type="submit" name="submit" id="submit" value="Update Item">'; echo "</div></td></tr><tr><td height='124' colspan='4'>"; echo '<strong>Seeking:</strong> <textarea name="in_return" cols="75" rows="5">' . $row['in_return'] . ' </textarea>'; echo "</td><td><div align='center'>"; if(isset($_SESSION['updatecomplete'])) { unset($_SESSION['updateerror']); echo $_SESSION['updatecomplete']; } if(isset($_SESSION['updateerror'])) { unset($_SESSION['updatecomplete']); echo $_SESSION['updateerror']; } echo "</div></td></tr><tr><td colspan='4'>"; echo '<input type="hidden" name="category" value="' . $row['category'] . '" size="25" />'; echo "</td><td><div align='center'>"; echo ''; echo "</td></tr>"; } echo "</table>"; $_SESSION['item_id_pass'] = $row['id']; // I try to echo this session var on another page,, but it does not appear. } else { echo '<div align="center">You currently have no pics.<br />Post your first pic now!</div>'; } ?> </form>
  10. This is just the extensio part of what I have.... If you can't figure out the rest,,, post your code that you have for your upload script. This will only allow .jpg ,,, you can add others. <?php $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg")) { Have your error here. } Just so you know,, this is far from secure from what I have heard. How,, I don't know.. Still learning myself
  11. I'm still confused,, I'll just play around with it. And look for some examples..
  12. Could you explain a tad bit more ??
  13. Hi,,, the image upload script that I'm using works fantastic(I think) for 1 image..Now lets say I have 5 file field boxes. What would be the easiest way to loop through all 5 boxes for upload?? Can someone get me started? <?php session_start(); include "connection.php"; mysql_connect("$host", "$username", "$password") or die("Could not connect."); mysql_select_db("$db_name") or die("Could not find database"); $item_name = mysql_real_escape_string($_POST['item_name']); $description = mysql_real_escape_string($_POST['description']); $in_return = mysql_real_escape_string($_POST['in_return']); define ("MAX_SIZE","1000"); 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['submit'])) { $image=$_FILES['image']['name']; if($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "gif") && ($extension != "png")) { $_SESSION['badformat'] = "Your picture must be a .JPG .GIF or .PNG"; header("location: http://www.---------.com/---------.php"); exit(); $errors=1; } else { $size=filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*1024) { $_SESSION['toobig'] = "Your picture can not exceed 1 megabyte."; header("location: http://www.---------.com/---------.php"); exit(); $errors=1; } $category = $_POST['listmenu']; $image_name=time().'.'.$extension; $newname="userimages/$category/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { $_SESSION['notcopy'] = "There was an error posting your trade. Please try again later."; header("location: http://www.-------.com/--------.php"); exit(); $errors=1; } } } } // if everything is good, post new item for the user $mysqlcategory = $category; $imgpath = $newname; $findit = $_SESSION['id']; $result=mysql_query("SELECT id FROM members WHERE username = '$findit'"); $row=mysql_fetch_assoc($result); $user_id = $row['id']; $sql = "INSERT INTO abcxyz(item_name, description, in_return, imgpath, category, user_id)VALUES('$item_name','$description','$in_return', '$imgpath', '$mysqlcategory', '$user_id')"; mysql_query($sql) or die(mysql_error()); // go to confirmation page if upload is completed. if(isset($_POST['submit']) && !$errors) { $_SESSION['picload'] = $newname; $_SESSION['picname'] = $item_name; header("location: http://www.-----------.com/---------.php"); exit(); } ?> Also,, when I add the extra file fields to my form,, should they be named the same,, or different?? I was thinking the same name so the script can cycle through all the file fields. Maybe with a Foreach statement??
  14. I don't know,, can you... I still learning a lot... But I think tomorrow I will just redo my page with all the forms separated.. Which sucks.. But oh well.
  15. I hope somebody chimes in saying that they have.. I really don't want to setup my page again.
  16. I thought it was because it use to work(the setup that I have). But now it will not.... What is the trick for nesting a form inside a form??? When I run the script inside form22,,, the action from form2 runs instead. Here is the form(s) setup. <form id="form2" name="form2" method="post" action="updatepic.php"> <?php session_start(); include "connection.php"; if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } $findit = $_SESSION['id']; $result = mysql_query("SELECT id FROM members WHERE username = '$findit' LIMIT 1"); $e_row = mysql_fetch_assoc($result); $query = mysql_query("SELECT count(*) FROM abcxyz WHERE user_id = " . $e_row['id']) or die(mysql_error()); $query_data = mysql_fetch_row($query); $numrows = $query_data[0]; $rows_per_page = 1; $lastpage = ceil($numrows/$rows_per_page); $pageno = (int)$pageno; $prevpage = $pageno-1; $nextpage = $pageno+1; if ($pageno > $lastpage) { $pageno = $lastpage; } if ($pageno < 1) { $pageno = 1; } $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; $sql = mysql_query("SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = " . $e_row['id'] . " $limit"); if($lastpage != 0) { echo "<table width='954' border='0' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#BBD4E1'>"; while ($row = mysql_fetch_array($sql)) { echo "<tr><td width='188' height='180'><div align='center'>"; echo '<img src="' . $row['imgpath'] . '" width="125" alt="" />'; echo "</div></td><td width='188'><div align='center'>"; if(empty($row['imgpath2'])) { echo '<form action="postnewitem.php" method="post" enctype="multipart/form-data" name="form22"> <div align="center"> <input name="image" type="file" id="image" size="15" input="input" /> <br> <input name="submit" type="submit" value="Upload Picture 2" id="submit" /> </div> </form>'; } else { echo '<img src="' . $row['imgpath2'] . '" width="125" alt="" />'; } echo "</div></td><td width='188'><div align='center'>"; echo '<img src="' . $row['imgpath3'] . '" width="125" alt="" />'; echo "</div></td><td width='188'><div align='center'>"; echo '<img src="' . $row['imgpath4'] . '" width="125" alt="" />'; echo "</div></td><td width='190'><div align='center'>"; echo '<img src="' . $row['imgpath5'] . '" width="125" alt="" />'; echo "</div></td></tr><tr><td height='43' colspan='4'>"; echo '<strong>Item Name:</strong> <input type="text" name="item_name" value="' . $row['item_name'] . '" size="50" /> '; if ($pageno == 1) { echo " Previous Item "; } else { echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'> Previous Item </a>"; } echo "($pageno of $lastpage)"; if ( $pageno == $lastpage ) { echo " Next Item "; } else { echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'> Next Item </a>"; } echo "</td><td><div align='center'>"; echo '<input type="hidden" name="id" value="' . $row['id'] . '" size="25" />'; echo "</div></td></tr><tr><td height='116' colspan='4'>"; echo '<strong>Description:</strong> <textarea name="description" cols="75" rows="5">' . $row['description'] . '</textarea>'; echo "</td><td><div align='center'>"; echo '<input type="submit" name="updatesubmit" id="updatesubmit" value="Update Item"><br><br><input type="submit" name="delete" id="delete" value="Delete Item ">'; echo "</div></td></tr><tr><td height='124' colspan='4'>"; echo '<strong>Seeking:</strong> <textarea name="in_return" cols="75" rows="5">' . $row['in_return'] . ' </textarea>'; echo "</td><td><div align='center'>"; if(isset($_SESSION['updatecomplete'])) { unset($_SESSION['updateerror']); echo $_SESSION['updatecomplete']; } if(isset($_SESSION['updateerror'])) { unset($_SESSION['updatecomplete']); echo $_SESSION['updateerror']; } //echo ''; echo "</div></td></tr><tr><td colspan='4'>"; echo '<input type="hidden" name="id" value="' . $row['category'] . '" size="25" />'; echo "</td><td><div align='center'>"; echo ''; echo "</td></tr>"; } echo "</table>"; } else { echo "You currently have no pics."; } ?> </form>
  17. i have a form with a script inside it that has an action... within that script,, I echo another form with a different action... Is this possible?
  18. Oh yeh,, by if statement is inside another form,,and both forms having different names.
  19. I get a progress bar moving,, then the page refreshes back to my form,, but no upload.. This use to work. <?php /////////////////////////////////////form page if(empty($row['imgpath2'])) { echo "<form action='postnewitem2.php' method='post' enctype='multipart/form-data' name='form22' id='form22'> <div align='center'> <input name='image' type='file' id='image' size='15' input='input' /> <br> <input name='submit' type='submit' value='Upload Picture 2' id='submit' /> </div> </form>"; } else { echo '<img src="' . $row['imgpath2'] . '" width="125" alt="" />'; } ?> <?php session_start(); require 'connection.php'; mysql_connect("$host", "$username", "$password") or die("Could not connect."); mysql_select_db("$db_name") or die("Could not find database"); $item_name = mysql_real_escape_string($_POST['item_name']); $id = mysql_real_escape_string($_POST['id']); $category = mysql_real_escape_string($_POST['category']); define ("MAX_SIZE","1000"); 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['submit'])) { $image=$_FILES['image']['name']; if($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "gif") && ($extension != "png")) { echo '<h1>Picture is not in correct format.</h1>'; $errors=1; } else { $size=filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit on your picture.</h1>'; $errors=1; } $image_name=time().'.'.$extension; $newname="userimages/$category/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>There was an error posting your pic. Please try again.</h1>'; $errors=1; } } } } $mysqlcategory = $category; $imgpath = $newname; $findit = $_SESSION['id']; $result=mysql_query("SELECT id FROM members WHERE username = '$findit'"); $row=mysql_fetch_assoc($result); $user_id = $row['id']; $sql = "INSERT INTO abcxyz(imgpath2)VALUES('$imgpath')WHERE id = '$id' and user_id = '$user_id'"; mysql_query($sql) or die(mysql_error()); if(isset($_POST['submit']) && !$errors) { echo "Complete"; unset($_SESSION['updatecomplete']); } ?>
  20. <?php $sql = "INSERT INTO abcxyz(imgpath2)VALUES('$imgpath')WHERE id = '$id' and user_id = '$user_id'"; ?> How would I get an echo for the mysql error if the insert was working?.. I know how to do it,, but I can't get the syntax right.
  21. Lets say the page that the user can look at their pics is called http://www.COOL.com/pics.php The pagination is setup for 1 picture at a time.... So when they click the next button,,, the URL reads as follows http://www.COOL.com/pics.php?pageno2 and so on.... When they do an update with picture number 2...... It takes them back to http://www.COOL.com/pics.php I would like it to keep them on pageno2..... Later down the road,,,, If they click on the delete button,,, I will have it take them to the picture that is previous to the one deleted.... But for now,,, I'm not worried about that.
  22. This is what gets the page number $_GET['pageno']
  23. I have a pagination setup with an update button on each page. Lets say I have 5 pictures to view, each one with its own page... And someone updates picture #2...After the update there is a header setting to keep them at the same page with a success message... header("location: http://www.xxxxxxxxxxxx.com/yyyyyyy.php"); The only problem is when they update picture #2 the URL is something like header("location: http://www.xxxxxxxxxx.com/yyyyyyy.php?pageno2"); What should I put in the header setting so it keeps them at the same picture after they update????
  24. True true,,,, I guess thinking too much is bad sometimes...LoL... Thanks for all the help bud.
×
×
  • 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.