Jump to content

justAnoob

Members
  • Posts

    561
  • Joined

  • Last visited

    Never

Everything posted by justAnoob

  1. little script here to edit mysql row data,,It will echo "Thank you! Information updated." But when I check my database,, the info never changed... Also, check the commented line below. <?php include "connection.php"; $id=$r["id"]; if ($_POST["submit"]) { $name = $_POST["item_name"]; $description = $_POST["description"]; $seeking = $_POST["in_return"]; $sql = "UPDATE $table1 SET item_name = '$name' WHERE id=$id"; $result = mysql_query($sql); echo "Thank you! Information updated."; echo $id; // tried to echo the row id,, but nothing comes up } ?> Here is one of the input boxes that I have on the form. <?php <input type="name" value="' . $row['item_name'] . '" size="50" /> ?>
  2. calling this solved although it is not... It is driving me crazy..... I got to this point... but it is still showing a box with a red x in it... When it should be saying "no picture here" <?php session_start(); include "connection.php"; $findit = $_SESSION['id']; $result = mysql_query("SELECT id FROM members WHERE username = '$findit'"); $result = mysql_result($result, 0, 0); $sql = mysql_query("SELECT imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM member_trades WHERE user_id = '$result'"); $img2query = mysql_query("SELECT imgpath2 FROM member_trades WHERE user_id = '$result'"); echo "<table width='954' height='523' border='1' 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 (mysql_num_rows($img2query) > 0) { echo '<img src="' . $row['imgpath2'] . '" width="125" alt="" />'; } else { echo "No picture yet."; } 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> ' . $row['item_name'] . ''; echo "</td><td><div align='center'>"; echo "previouse next buttons"; echo "</div></td></tr><tr><td height='116' colspan='4'>"; echo '<strong>Description:</strong> ' . $row['description'] . ''; echo "</td><td><div align='center'>"; echo "</div></td></tr><tr><td height='124' colspan='4'>"; echo '<strong>Item wanted or price:</strong> ' . $row['in_return'] . ''; echo "</td><td><div align='center'>"; echo "</div></td></tr><tr><td colspan='4'>"; echo "save delete buttons"; echo "</td><td><div align='center'>"; echo "</td></tr>"; } echo "</table>"; ?>
  3. <?php 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"> <?php if (mysql_num_rows($img2query) > 0) { echo "<img src="' . $row['imgpath2'] . '" width="125" alt="" />"; } else { echo "No picture yet."; } ?>'; 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> ' . $row['item_name'] . ''; echo "</td><td><div align='center'>"; echo "previouse next buttons"; echo "</div></td></tr><tr><td height='116' colspan='4'>"; echo '<strong>Description:</strong> ' . $row['description'] . ''; echo "</td><td><div align='center'>"; echo "</div></td></tr><tr><td height='124' colspan='4'>"; echo '<strong>Item wanted or price:</strong> ' . $row['in_return'] . ''; echo "</td><td><div align='center'>"; echo "</div></td></tr><tr><td colspan='4'>"; echo "save delete buttons"; echo "</td><td><div align='center'>"; echo "</td></tr>"; } echo "</table>"; ?> Can I have a script inside a script??
  4. So I should just be able to put my script inside the div and I should be ok right?
  5. I have a table that is echoed out with pictures in separate sections of the table.... Instead of just echoing the picture... like so <?php echo '<img src="' . $row['imgpath2'] . '" width="125" alt="" />'; ?> I want a script in place of that echo saying that if the image is in mysql,, then show the image.... and if there is no image,, then say that there is no image..... here is the rest of the script.... <?php session_start(); include "connection.php"; $findit = $_SESSION['id']; $result = mysql_query("SELECT id FROM members WHERE username = '$findit'"); $result = mysql_result($result, 0, 0); $sql = mysql_query("SELECT imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM member_trades WHERE user_id = '$result'"); $img2query = mysql_query("SELECT imgpath2 FROM member_trades WHERE user_id = '$result'"); echo "<table width='954' height='523' border='1' 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'>"; //echo '<img src="' . $row['imgpath2'] . '" width="125" alt="" />'; // this was the original line that I had but it did not work as I wanted it to... this line would return just a empty box with a red x in it if there was no picture in mysql database... if (mysql_num_rows($img2query) > 0) { echo '<img src="' . $row['imgpath2'] . '" width="125" alt="" />'; } else { echo "No picture yet."; } 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> ' . $row['item_name'] . ''; echo "</td><td><div align='center'>"; echo "previouse next buttons"; echo "</div></td></tr><tr><td height='116' colspan='4'>"; echo '<strong>Description:</strong> ' . $row['description'] . ''; echo "</td><td><div align='center'>"; echo "</div></td></tr><tr><td height='124' colspan='4'>"; echo '<strong>Item wanted or price:</strong> ' . $row['in_return'] . ''; echo "</td><td><div align='center'>"; echo "</div></td></tr><tr><td colspan='4'>"; echo "save delete buttons"; echo "</td><td><div align='center'>"; echo "</td></tr>"; } echo "</table>"; ?>
  6. smartass remark,,,, what are you talking about??? Does no one understand what I'm trying to do???
  7. if(mysql_num_rows($img2query) > 0)) i put the other ) on the line but still an error with the commented line... I notice that the comment did not turn yellow....
  8. keep getting error on this line..... <?php echo 'if(mysql_num_rows($img2query) > 0) { echo "<img src="' . $row['imgpath2'] . '" width='125' alt="" />"; // this line here } else { echo "No picture yet." }'; ?>
  9. I have a new posted topic..Started new one by accident...
  10. right now i have a line of code that says <?php echo '<img src="' . $row['imgpath2'] . '" width='125' alt="" />'; ?> I'm looking to put this in it's place.... <?php if(mysql_num_rows($img2query) > 0) { echo '<img src="' . $row['imgpath2'] . '" width='125' alt="" />'; } else { echo "No picture yet."; } ?> Can I echo an IF statement???
  11. i know php and how to to create the image input field. so would i say something like if imgpath2 is empty, show input field else, show field... of course use real php.. so to find imgpath2,, I would do a query for imgpath2 and then create a variable from that and then use php to see if it contains a picture or not,, right????
  12. I have this line located in a table. <?php echo '<img src="' . $row['imgpath2'] . '" width="125" alt="" />'; ?> As of right now the row in mysql that is named imgpath2 has nothing in it,,, so it just shows a box with a little red x in it. What I'm looking to do is instead of showing that box with the little red x... I would like a file field box to appear...So then when an image is uploaded(imgpath2),, the picture would then appear and the file field box would be gone.. So something like this... if imgpath2 is empty...show file field box else show picture PHP for this one???
  13. thanks premiso.... What exactly does the 0, 0 do???
  14. I changed the script around a little,, but still the same basic idea.... Still can't get it to work... Something so simple,, it's killing me.... Here is the revised script... The table appears but no images or info. <?php session_start(); include "connection.php"; $findit = $_SESSION['id']; $query = mysql_query("SELECT id FROM members WHERE username = '$findit'"); $result = mysql_query($query); $sql = mysql_query("SELECT imgpath, item_name FROM member_trades WHERE user_id = '$result'"); //this line echo "<table border='0' CELLPADDING=5 STYLE='font-size:16px'>"; echo "<table border=1><tr><td><H3>Image </h3></td> <td><H3>Item&nbspName</H3></td></tr>"; while ($row = mysql_fetch_array($sql)) { echo "<tr><td align='center'>"; echo '<img src="' . $row['imgpath'] . '" width="125" alt="" />'; echo "</td><td align='center'>"; echo $row['item_name']; echo "</td></tr>"; } echo "</table>"; ?> I echoed out $findit and the username appears,,, which is great,,, that works. session_start is there. I changed the commented line to the line below(1 is just a member id)and it echoes that table with the pics. <?php $sql = mysql_query("SELECT imgpath, item_name FROM member_trades WHERE user_id = '1'"); ?> So something is not working right..... My tables are set up the following.... table "members" id username table "member_trades" userid imgpath item_name Can you spot the prob????
  15. i changed it around a little and put in a user_id directly into script and it works fine. <?php include "connection.php"; $findme = $_SESSION['id']; $query = "SELECT id FROM members WHERE username = '$findme'"; $result = mysql_query($query); $sql = mysql_query("SELECT imgpath, item_name FROM member_trades WHERE user_id = '20'"); echo "<table border='0' CELLPADDING=5 STYLE='font-size:16px'>"; echo "<table border=1><tr><td><H3>Image </h3></td> <td><H3>Item&nbspName</H3></td></tr>"; while ($row = mysql_fetch_array($sql)) { echo "<tr><td align='center'>"; echo '<img src="' . $row['imgpath'] . '" width="125" alt="" />'; echo "</td><td align='center'>"; echo $row['item_name']; echo "</td></tr>"; } echo "</table>"; ?> But when I go back to the variable,,,, it doesn't show the info. <?php include "connection.php"; $findme = $_SESSION['id']; $query = "SELECT id FROM members WHERE username = '$findme'"; $result = mysql_query($query); $sql = mysql_query("SELECT imgpath, item_name FROM member_trades WHERE user_id = '$result'"); echo "<table border='0' CELLPADDING=5 STYLE='font-size:16px'>"; echo "<table border=1><tr><td><H3>Image </h3></td> <td><H3>Item&nbspName</H3></td></tr>"; while ($row = mysql_fetch_array($sql)) { echo "<tr><td align='center'>"; echo '<img src="' . $row['imgpath'] . '" width="125" alt="" />'; echo "</td><td align='center'>"; echo $row['item_name']; echo "</td></tr>"; } echo "</table>"; ?>
  16. i have two tables in mysql,,,, one table has "id" and "username" and the other table has "user_id" "imgpath" and "item_name" Do you see what I'm trying to accomplish below???? <?php include "connection.php"; $findit = $_SESSION['id']; $result = mysql_query("SELECT id FROM members WHERE username = '$findit'"); $foundit = $result $sql = mysql_query("SELECT imgpath, item_name FROM member_trades WHERE user_id = $foundit"); echo "<table border='0' CELLPADDING=5 STYLE='font-size:16px'>"; echo "<table border=1><tr><td><H3>Image </h3></td> <td><H3>Item&nbspName</H3></td></tr>"; while ($row = mysql_fetch_array($sql)) { echo "<tr><td align='center'>"; echo '<img src="' . $row['imgpath'] . '" width="125" alt="" />'; echo "</td><td align='center'>"; echo $row['item_name']; echo "</td></tr>"; } echo "</table>"; ?> I'm looking to dispaly all the pictures from whatever user is signed in. See anything that is wrong??? The error I get is "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result " Everything seems right
  17. I tried doing the functin for each upload,, but couldn't get it to work.... Any suggestions or some code snippets?
  18. but wouldn't the script change if I had 5 different filefields for the uploads????? image image2 image3 and so on.
  19. Here is a correction of the original script that I'm working with... <?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")) { 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 one of your pictures.</h1>'; $errors=1; } $category = $_POST['listmenu']; $image_name=time().'.'.$extension; $newname="userimages/$category/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>File #1 unsuccessfull!</h1>'; $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 xxxxxxxxx(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) { header ("http://www.xxxxxxxxxx.com/previewsave.php"); echo "<h1>Image Uploaded Successfully!</h1>"; echo '<img src="' . $newname . '" width="150" border="0"><br />'; } ?>
  20. I tried doing something like this..... if(!empty(image2)) { run the upload script again just changing the variables to work with the filefield name "image2" } if(!empty(image3)) { run the upload script etc........ } But i think I ran into the problem where everything gets inserted into MySQL Here is the line originally with just having 1 upload box.. <?php $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 xxxxxxxxx(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());?> Then when I add the other image2, image3, image4 and image5 filefield boxes for optional upload...that would just create a ton variables and a big mess.?..... Could I do a loop of some sort??? I'm not that good with loops.
  21. this script works great for uploading 1 picture into my server directory and the image path to mysql. As you can see below my filefield name is "image" for the one picture that can be uploaded. If I added 4 more fields.... "image2" "image3" "image4" "image5" to my form... Would it be complicated to just add the upload of these fields into the script???? The first image is required when you upload,,,, but the other 4 will not be required. I'm kinda confused,, other people tell me to just start with a new script... But I like the one I have. <?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")) { echo '<h1>Picture #1 is not in correct format.</h1>'; $errors=1; } else { $size=filesize($_FILES['image']['tmp_name']); $size2=filesize($_FILES['image2']['tmp_name2']); if ($size || $size2 > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit on one of your pictures.</h1>'; $errors=1; } $category = $_POST['listmenu']; $image_name=time().'.'.$extension; $newname="userimages/$category/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>File #1 unsuccessfull!</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 member_trades(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) { header ("http://www.xxxxxxxxxxx.com/previewsave.php"); echo "<h1>Image Uploaded Successfully!</h1>"; echo '<img src="' . $newname . '" width="150" border="0"><br />'; } ?>
  22. here i have a image upload script that works great... what im looking to do is have the user be able to upload 5 pictures if they want... i have the 5 file fields on the page ready to go,,, the 1st one works great and is required by the user(they must have atleast 1 picture to be uploaded,,, and a max of 5)... Would this be a good way to accomplish this???? upload script for image if filefield[image2] is not empty upload script if filefield[image3] is not empty upload script if filefield[image4] is not empty upload script if filefield[image5] is not empty upload script If this way is ok to do,, how would I word the if statement correctly?????
  23. <?php echo "".substr($row['description'],0,50),"<span class='style666'><a href='http://xxxxxxxxx.com/viewitem.php'> ...View</a></span>"; ?> Got this to work with no errors, but the style is not applied. .style666 { color: #0099FF; text-decoration: none; }
  24. <?php echo "".substr($row['description'],0,50),"<a href='http://xxxxxxxx.com/viewitem.php'> ...View</a>"; ?> This works without the span class, having problems inserting the class though.
×
×
  • 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.