Jump to content

RyanW67

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

RyanW67's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry - yeah I tried it, the first image would always upload but the second would not... I think what I've done wrong is somewhere in $copy = copy ($_FILES['file']['tmp_name'], "$folder/".$_FILES['file']['name']); $copy2 = copy ($_FILES['file2']['tmp_name'], "$folder/".$_FILES['file2']['name']); $imagename = $_FILES['file']['name']; $imagename2 = $_FILES['file']['name2'];
  2. I've made this single image uploader using a tutorial, basically I want to adapt so it uploaded multiple images in one go. I've seen quite a few scripts online for multi-image uploaders but I'm quite curious if what I'm trying to do is possible with this script... Here is the original code <?php if (isset($_GET['upload'])) { $folder = "../carimages/"; if ($_FILES['file']['type'] == "image/gif" || "image/jpg") { $copy = copy ($_FILES['file']['tmp_name'], "$folder/".$_FILES['file']['name']); $imagename = $_FILES['file']['name']; if (!$copy) { echo "<font face=\"Arial\" size=\"2\">Image could not be uploaded at this time, <a href=\"addform.php\">return to Admin add page</a>"; } else { echo "Image uploaded. <a href=\"index.php\">return to Admin page</a>"; echo "$imagename"; } } else { echo "Wrong file type, <a href=\"index.php\">return to Admin page</a>."; } } else { echo "<font face=\"Arial\" size=\"2\"><br /><br />If you do not need to upload a picture, you can <a href=\"index.php\">return to Admin section</a><br /><br /><b>Image Upload</b><br /><br /><form action='?upload' method='post' enctype='multipart/form-data'> <input type='file' name='file'> <input type='submit' value='Upload'> </form></font>"; } ?> And I was wondering if I did this (below) to the code, would it make it possible to upload two images at the same time: <?php if (isset($_GET['upload'])) { $folder = "../carimages/"; if ($_FILES['file']['type'] == "image/gif" || "image/jpg") if ($_FILES['file2']['type'] == "image/gif" || "image/jpg") { $copy = copy ($_FILES['file']['tmp_name'], "$folder/".$_FILES['file']['name']); $copy2 = copy ($_FILES['file2']['tmp_name'], "$folder/".$_FILES['file2']['name']); $imagename = $_FILES['file']['name']; $imagename2 = $_FILES['file']['name2']; if (!$copy) { echo "<font face=\"Arial\" size=\"2\">Image could not be uploaded at this time, <a href=\"addform.php\">return to Admin add page</a>"; } if (!$copy2) { echo "<font face=\"Arial\" size=\"2\">Image 2 could not be uploaded at this time, <a href=\"addform.php\">return to Admin add page</a>"; } else { echo "Image uploaded. <a href=\"index.php\">return to Admin page</a>"; echo "$imagename"; echo "$imagename2"; } } else { echo "Wrong file type, <a href=\"index.php\">return to Admin page</a>."; } } else { echo "<font face=\"Arial\" size=\"2\"><br /><br />If you do not need to upload a picture, you can <a href=\"index.php\">return to Admin section</a><br /><br /><b>Image Upload</b><br /><br /><form action='?upload' method='post' enctype='multipart/form-data'> <input type='file' name='file'> <input type='file' name='file2'> <input type='submit' value='Upload'> </form></font>"; } ?> I know it's a bit of a bodge attempt but am in quite a rush! Sorry about the lack of indentations, have copied it straight from my online web editor. All help appreciated Ryan
  3. Dear all, I'm quite a php noobie, have used a tutorial to construct a php image uploader. Though I'm now faced a problem regarding the directory where the image is uploaded to... I have the variable $folder which holds the address of the web folder in which the image is to be uploaded to... However the image will only upload when this variable is set to a folder which is in the same folder as the upload script.... for example I have a secure area/folder called CMS, in this I have the upload file and the upload folder (images), however I don't want to the upload folder to be in the secure area (as it wouldn't allow visitors to see the images) so instead I have tried changing the variable to say $folder = "http://www.myhost.co.uk/images/"; instead of $folder = "http://www.myhost.co.uk/CMS/images/"; (which works fine)... Does this mean I have to upload to wherever my script is? Thanks in advance Ryan
  4. Hi All, Like my previous post I'm quite a Php noobie, been using a tutorial to make an image uploader, and want to further the uploader so that when it uploads the image the name of that file is assigned to a variable? I've got this... $copy = copy ($_FILES['file']['tmp_name'], "$folder/".$_FILES['file']['name']); $imagename = $_FILES['name']; The first line being when it copies the file from local to my server. I've made up the second line in hope of it working - but it doesn't.... Any ideas? Many Thanks Ryan
  5. Thank you very much While we're on topic, what would you recommend being the easiest way to remove duplicates? (there will be duplicates in the column and I only want them to appear once)
  6. Hi All, I've searched the net for examples and have really hit a stump, I'm quite a newbie to MySQL so would really appreciate it if any of you guys could help... Basically I'm setting up a website which needs an populated drop down box made up from all fields in a specific column of a table in a mysql db.... Here's the code I've made up using various tutorials.... <?php $user = ""; $host = "" $password = "" $dbName = "" /* make connection to database */ mysql_connect($host, $user, $password) OR DIE( "Unable to connect to database"); mysql_select_db($dbName); //did you forget this line? $sql = "SELECT model FROM usedVehicles"; $query = mysql_query($sql) or die(mysql_error() . "<br>$sql"); //use the or die(...) part ONLY IN DEVELOPMENT ?> <form action="action" method="post"> <select name="option"> <?php while ($row = mysql_fetch_array($result)) { echo "<option value=\"" . $row['model'] . "\">" . $row['model'] . "</option>\n"; } ?> </select> <input type="submit"> </form> I've left out the connection details for obvious reasons... When I upload and try to test this, jus a blank drop down appears... there are definately fields in the column as I have tried the query on phpMyAdmin... All help is really appreciated. Ryan
  7. Sorry, I mean entering own criteria via my form, there 3 drop down menus in my form for area, rooms and maxprice. And im using get. thanks. edit: appologies don't think Im being clear - basically when my page loads up with the form in, if I just leave the the form as it is without selecting anything (there are default values) and press search, then it loads up the results with all the rows printed out, though if I change the criteria, it searches and returns the correct results everytime..... not sure why this is happening.
  8. Hey Guys, I'm new to this forum and haven't really been studying PHP relatively long, having a bit of an odd one at the moment though... Basically I followed a tutorial, and have now customised the search for my own purpose, the problem I'm having is that the first time I search via my form... it prints alls the rows from my table, however - after then whenever I put in my own criteria it works fine...? Below is the code im using for my search.php which my html form points at... (i've taken out the security details for obv reasons) hopefully I've complied to all the posting rules... thanks! <?php $hostname = ""; $username = ""; $password = ""; $dbName = ""; $table = "houses"; MYSQL_CONNECT($hostname, $username, $password) OR DIE( "Unable to connect to database"); $number = 0; $house_title = @$_GET['house_title'] ; $house_desc = @$_GET['house_desc'] ; $house_rooms = @$_GET['house_rooms'] ; $house_area = @$_GET['house_area'] ; $house_type = @$_GET['house_type'] ; $house_pic = @$_GET['house_pic'] ; $house_price = @$_GET['house_price'] ; @mysql_select_db("$dbName") or die( "Unable to select database"); if ($house_area == "house_area") {$house_area = '%';} if ($house_rooms == "house_rooms") {$house_rooms = '%';} if ($house_price == "house_price") {$house_price = '%';} if ($house_desc == "") {$house_desc == '%';} if ($house_pic == "") {$house_pic == '%';} if ($house_title == "") {$house_title == '%';} $query = ("SELECT * FROM $table WHERE house_area LIKE '$house_area%' AND house_rooms LIKE '$house_rooms%' AND house_price LIKE '$house_price%'"); $result = MYSQL_QUERY($query); /* Determine the number of records returned */ while ($row=MYSQL_FETCH_ROW($result)) $number = mysql_numrows($result); if ($number == 0) { print ("Unfortunately, there are no properties which match your criteria."); } if ($number != 0) { /* Print the relevant information */ $i = 0; echo "<font face=\"Verdana, Arial, Helvetica, sans-serif\"> <b>There are $number records in the inventory:</b></font><p>"; echo "<table cellpadding=5>"; echo " <TR bgcolor=black> <td><font face=\"Verdana, Arial,Helvetica, sans-serif\" size=\"-1\" color=white><b>House Title</b></font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\" color=white><b>Rooms</b></font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\" color=white><b>Price</b></font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\" color=white><b>Area</b></font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\" color=white><b>Description</b></font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\" color=white><b>Picture</b></font></td> </tr>"; while ($i < $number): $house_title = mysql_result($result, $i,"house_title"); $house_rooms = mysql_result($result, $i,"house_rooms"); $house_price = mysql_result($result,$i,"house_price"); $house_area = mysql_result($result,$i,"house_area"); $house_desc = mysql_result($result,$i,"house_desc"); $house_pic = mysql_result($result,$i,"house_pic"); if ($i%2 == 0) { echo "<tr bgcolor=lightgrey> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\">$house_title</font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\"> $house_rooms</font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\"> $house_price</font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\"> $house_area</font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\"> $house_desc</font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\"> $house_pic</font></td> </tr>"; } else { echo "<tr bgcolor=lightgreen> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\">$house_title</font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\"> $house_rooms</font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\"> $house_price</font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\"> $house_area</font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\"> $house_desc</font></td> <td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\"> $house_pic</font></td> </tr>"; } $i++; endwhile; echo "</table>"; } /* Close database connection */ MYSQL_CLOSE(); ?>
×
×
  • 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.