Jump to content

joshgarrod

Members
  • Posts

    283
  • Joined

  • Last visited

    Never

Everything posted by joshgarrod

  1. Sure: <?php $logo = $info ['logo']; $pos = strpos($logo, "../");//check if image contains ../ if ($pos != 0) {} else { $logo = substr($logo, 3);} $image1 = $info ['image1']; $pos1 = strpos($image1, "../");//check if image contains ../ if ($pos1 != 0) {} else { $image1 = substr($image1, 3);} $image2 = $info ['image2']; $pos2 = strpos($image2, "../");//check if image contains ../ if ($pos2 != 0) {} else { $image2 = substr($image2, 3);} $image3 = $info ['image3']; $pos3 = strpos($image3, "../"); //check if image contains ../ if ($pos3 != 0) {} else { $image3 = substr($image3, 3);} ?>
  2. i still does the same, is there any other way of checking if the string contains ../ and if it does strip it off?
  3. Hi, I am trying to search a string for a string of characters in this order ../ and carry out relevant if statements but it returns the same result every time. On echoing my $pos, $pos2, $pos3 and $pos4 variables the first two come back 0 and they are the strings that do contain ../ but the if statements perform the same? I don't understand, any ideas? Thanks... <?php $logo = $info ['logo']; $pos = strpos($logo, "../");//check if image contains ../ if ($pos == 0) {} else { $logo = substr($logo, 3);} $image1 = $info ['image1']; $pos1 = strpos($image1, "../");//check if image contains ../ if ($pos1 == 0) {} else { $image1 = substr($image1, 3);} $image2 = $info ['image2']; $pos2 = strpos($image2, "../");//check if image contains ../ if ($pos2 == 0) {} else { $image2 = substr($image2, 3);} $image3 = $info ['image3']; $pos3 = strpos($image3, "../"); //check if image contains ../ if ($pos3 == 0) {} else { $image3 = substr($image3, 3);} ?>
  4. Hi, I am searching for a basic, easy to implement php form validation script that checks if the user has filled out a field, if they havent to tell them so. i have tried basic if statements but it refreshes the page and all the other fields that were filled in are clear. Anyone know of any tricks or scripts that are good? Thanks in advance.
  5. Never mind I managed to figure it out, thank you so much
  6. Thanks for taking the time to reply. So if I stick the main script in a seperate file, include it in my upload script and then once the image has been uploaded call the function using the code at the bottom? (Sorry I am trying to get to grips with all of this)
  7. Hi, I have a script that uploads an image to a directory and then saves the fill path to a field in a table for later use. The only problem is people are uploading huge images and then when I produce a catalogue of my listings it takes forever to load because the images are so big. What I am after is an add in script to create an ADDITIONAL image 100 x 75px, I don't really want to change my upload script. Any ideas? Thanks in advace. Here is what I have: <?php $idir = "../fleet/"; // Path To Images Directory if (isset ($_FILES['fupload'])){ //upload the image to tmp directory $url = $_FILES['fupload']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload']['type'] == "image/jpg" || $_FILES['fupload']['type'] == "image/jpeg" || $_FILES['fupload']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload']['name'], '$account.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload']['tmp_name'], "$idir" . $_FILES['fupload']['name']); // Move Image From Temporary Location To Perm } } $fleetimage1 = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); //then insert sql code below... ?>
  8. Hi, it is similar to what I used before, I still can't get it to work, here is my code now, I have only made changes to the first image: <?php $idir = "../fleet/"; // Path To Images Directory if (isset ($_FILES['fupload'])){ //upload the image to tmp directory $url = $_FILES['fupload']['name']; // Set $url To Equal The Filename For Later Use list($width, $height) = getimagesize($url); $image_height = 300; $image_width = $width * ($image_height / $height); $imagenew = imagecreatefromjpeg($url); //scale to height if ($_FILES['fupload']['type'] == "image/jpg" || $_FILES['fupload']['type'] == "image/jpeg" || $_FILES['fupload']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $imageset = imagecreatetruecolor($image_width, $image_height); imagecopyresampled($imageset, $imagenew, 0, 0, 0, 0, $image_width, $image_height, $width, $height); $newname = 'fupload'.$account.'.jpg'; $output_file="../fleet/".$newname; imagejpeg($imageset, $output_file, 100); // Move Image From Temporary Location To Perm } } if (isset ($_FILES['fupload2'])){ //upload the image to tmp directory $url = $_FILES['fupload2']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload2']['type'] == "image/jpg" || $_FILES['fupload2']['type'] == "image/jpeg" || $_FILES['fupload2']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload2']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload2']['tmp_name'], "$idir" . $_FILES['fupload2']['name']); // Move Image From Temporary Location To Perm } } if (isset ($_FILES['fupload3'])){ //upload the image to tmp directory $url = $_FILES['fupload3']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload3']['type'] == "image/jpg" || $_FILES['fupload3']['type'] == "image/jpeg" || $_FILES['fupload3']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload3']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload3']['tmp_name'], "$idir" . $_FILES['fupload3']['name']); // Move Image From Temporary Location To Perm } } if (isset ($_FILES['fupload4'])){ //upload the image to tmp directory $url = $_FILES['fupload4']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload4']['type'] == "image/jpg" || $_FILES['fupload4']['type'] == "image/jpeg" || $_FILES['fupload4']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload4']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload4']['tmp_name'], "$idir" . $_FILES['fupload4']['name']); // Move Image From Temporary Location To Perm } } error_reporting (E_ALL ^ E_NOTICE); $usr = "user"; $pwd = "pass"; $db = "db"; $host = "host"; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); } if ($_POST['submit']) { //***this is new between here... //****and here... $fleetmake = mysql_real_escape_string($_POST['fleetmake']); $fleetmodel = mysql_real_escape_string($_POST['fleetmodel']); $fleetyear = mysql_real_escape_string($_POST['fleetyear']); $fleetberth = mysql_real_escape_string($_POST['fleetberth']); $fleetlength = mysql_real_escape_string($_POST['fleetlength']); $fleetchassis = mysql_real_escape_string($_POST['fleetchassis']); $fleetengine = mysql_real_escape_string($_POST['fleetengine']); $fleetlayout = mysql_real_escape_string($_POST['fleetlayout']); $fleettype = mysql_real_escape_string($_POST['fleettype']); $fleetcomments = mysql_real_escape_string($_POST['fleetcomments']); $pricelow = mysql_real_escape_string($_POST['pricelow']); $pricemid = mysql_real_escape_string($_POST['pricemid']); $pricehigh = mysql_real_escape_string($_POST['pricehigh']); $fleetlocation = mysql_real_escape_string($_POST['fleetlocation']); $fleetimage1 = $output_file; $fleetimage2 = mysql_real_escape_string("$idir" . $_FILES['fupload2']['name']); $fleetimage3 = mysql_real_escape_string("$idir" . $_FILES['fupload3']['name']); $fleetimage4 = mysql_real_escape_string("$idir" . $_FILES['fupload4']['name']); $fleetadded = date("F j, Y, g:i a"); $fleetof = $account; $searchtags = "$fleetmake $fleetmodel $fleetberth berth motorhome for hire year $fleetyear $fleetmodel $fleetmake $fleetchassis motorhome $fleetmake $fleetmodel $fleetchassis $fleetmake $fleetchassis $fleettype $fleetlayout $fleetmake motorhome $fleetmodel motorhome $fleetberth berth motorhome $fleetmake $fleetberth berth motorhome $fleetmake motorhomes $fleetmake motor home $fleetmake motor homes $fleetmodel motorhomes $fleetlocation motorhome hire motorhome hire in $fleetlocaiton $fleetmake $fleetlocation $fleetmake $fleetmodel $fleetlocation"; $SQL = " INSERT INTO fleet "; $SQL .= " (fleetmake, fleetmodel, fleetyear, fleetberth, fleetlength, fleetchassis, fleetengine, fleetlayout, fleettype, fleetcomments, pricelow, pricemid, pricehigh, fleetlocation, fleetimage1, fleetimage2, fleetimage3, fleetimage4, fleetadded, fleetof, searchtags) VALUES "; $SQL .= " ('$fleetmake', '$fleetmodel', '$fleetyear', '$fleetberth', '$fleetlength', '$fleetchassis', '$fleetengine', '$fleetlayout', '$fleettype', '$fleetcomments', '$pricelow', '$pricemid', '$pricehigh', '$fleetlocation', '$fleetimage1', '$fleetimage2', '$fleetimage3', '$fleetimage4', '$fleetadded', '$fleetof', '$searchtags') "; $result = mysql_db_query($db,$SQL,$cid); $last=mysql_insert_id(); if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } header("location:fleet_add_confirm.php?last=$last"); exit(); } ?>
  9. Hi, I have a new website I have been working on for the past 6 months supposed to be going live on Jan 1st. It is my first attemp at a home made CMS and I am now in BETA stages, my testers have mentioned that my image upload script is not perfect. At the moment my images simply upload with no alterations. What they have suggested and I agree is that the images should be resized on upload and have unique names. I have tried to do both but failed. I have managed to change the name of the image that is being uploaded by putting random numbers on the end but the name that is stored in the table is the original name and I can't get it to add the random numbers on the end. The other task I totally failed at and have been working on all week and broke my code so bad I have now reverted back to square one. Could someone please help me to add image resize on upload and to put the new image name into my table, I wld be most greatful. Thanks in advance for your time. <?php $idir = "../fleet/"; // Path To Images Directory if (isset ($_FILES['fupload'])){ //upload the image to tmp directory $url = $_FILES['fupload']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload']['type'] == "image/jpg" || $_FILES['fupload']['type'] == "image/jpeg" || $_FILES['fupload']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload']['tmp_name'], "$idir" . $_FILES['fupload']['name'], $file_ext).rand(10000 , 99999).$file_ext); // Move Image From Temporary Location To Perm } } if (isset ($_FILES['fupload2'])){ //upload the image to tmp directory $url = $_FILES['fupload2']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload2']['type'] == "image/jpg" || $_FILES['fupload2']['type'] == "image/jpeg" || $_FILES['fupload2']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload2']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload2']['tmp_name'], "$idir" . $_FILES['fupload2']['name'], $file_ext).rand(10000 , 99999).$file_ext); // Move Image From Temporary Location To Perm } } if (isset ($_FILES['fupload3'])){ //upload the image to tmp directory $url = $_FILES['fupload3']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload3']['type'] == "image/jpg" || $_FILES['fupload3']['type'] == "image/jpeg" || $_FILES['fupload3']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload3']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload3']['tmp_name'], "$idir" . $_FILES['fupload3']['name'], $file_ext).rand(10000 , 99999).$file_ext); // Move Image From Temporary Location To Perm } } if (isset ($_FILES['fupload4'])){ //upload the image to tmp directory $url = $_FILES['fupload4']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload4']['type'] == "image/jpg" || $_FILES['fupload4']['type'] == "image/jpeg" || $_FILES['fupload4']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload4']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload4']['tmp_name'], "$idir" . $_FILES['fupload4']['name'], $file_ext).rand(10000 , 99999).$file_ext); // Move Image From Temporary Location To Perm } } error_reporting (E_ALL ^ E_NOTICE); $usr = "user"; $pwd = "pass"; $db = "db"; $host = "host"; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); } if ($_POST['submit']) { $fleetmake = mysql_real_escape_string($_POST['fleetmake']); $fleetmodel = mysql_real_escape_string($_POST['fleetmodel']); $fleetyear = mysql_real_escape_string($_POST['fleetyear']); $fleetberth = mysql_real_escape_string($_POST['fleetberth']); $fleetlength = mysql_real_escape_string($_POST['fleetlength']); $fleetchassis = mysql_real_escape_string($_POST['fleetchassis']); $fleetengine = mysql_real_escape_string($_POST['fleetengine']); $fleetlayout = mysql_real_escape_string($_POST['fleetlayout']); $fleettype = mysql_real_escape_string($_POST['fleettype']); $fleetcomments = mysql_real_escape_string($_POST['fleetcomments']); $pricelow = mysql_real_escape_string($_POST['pricelow']); $pricemid = mysql_real_escape_string($_POST['pricemid']); $pricehigh = mysql_real_escape_string($_POST['pricehigh']); $fleetlocation = mysql_real_escape_string($_POST['fleetlocation']); $fleetimage1 = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); $fleetimage2 = mysql_real_escape_string("$idir" . $_FILES['fupload2']['name']); $fleetimage3 = mysql_real_escape_string("$idir" . $_FILES['fupload3']['name']); $fleetimage4 = mysql_real_escape_string("$idir" . $_FILES['fupload4']['name']); $fleetadded = date("F j, Y, g:i a"); $fleetof = $account; $searchtags = "$fleetmake $fleetmodel $fleetberth berth motorhome for hire year $fleetyear $fleetmodel $fleetmake $fleetchassis motorhome $fleetmake $fleetmodel $fleetchassis $fleetmake $fleetchassis $fleettype $fleetlayout $fleetmake motorhome $fleetmodel motorhome $fleetberth berth motorhome $fleetmake $fleetberth berth motorhome $fleetmake motorhomes $fleetmake motor home $fleetmake motor homes $fleetmodel motorhomes $fleetlocation motorhome hire motorhome hire in $fleetlocaiton $fleetmake $fleetlocation $fleetmake $fleetmodel $fleetlocation"; $SQL = " INSERT INTO fleet "; $SQL .= " (fleetmake, fleetmodel, fleetyear, fleetberth, fleetlength, fleetchassis, fleetengine, fleetlayout, fleettype, fleetcomments, pricelow, pricemid, pricehigh, fleetlocation, fleetimage1, fleetimage2, fleetimage3, fleetimage4, fleetadded, fleetof, searchtags) VALUES "; $SQL .= " ('$fleetmake', '$fleetmodel', '$fleetyear', '$fleetberth', '$fleetlength', '$fleetchassis', '$fleetengine', '$fleetlayout', '$fleettype', '$fleetcomments', '$pricelow', '$pricemid', '$pricehigh', '$fleetlocation', '$fleetimage1', '$fleetimage2', '$fleetimage3', '$fleetimage4', '$fleetadded', '$fleetof', '$searchtags') "; $result = mysql_db_query($db,$SQL,$cid); $last=mysql_insert_id(); if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } header("location:fleet_add_confirm.php?last=$last"); exit(); } ?>
  10. awesome, thanks v much for your help - all sorted
  11. Hi, I was connecting further up, here is my code: <?php $con = mysql_connect("host","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("quest", $con); $idir = "../fleet/"; // Path To Images Directory if (isset ($_FILES['fupload'])){ //upload the image to tmp directory $url = $_FILES['fupload']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload']['type'] == "image/jpg" || $_FILES['fupload']['type'] == "image/jpeg" || $_FILES['fupload']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload']['tmp_name'], "$idir" . $_FILES['fupload']['name']); // Move Image From Temporary Location To Permanent Location } } if (isset($_POST['submit'])){ //$fleetref=$_POST["fleetref"]; $fleetimage1 = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); $fleetimage2 = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); $fleetimage3 = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); $fleetimage4 = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); # setup SQL statement if ($image == "1") { $query = sprintf("UPDATE `fleet` SET `fleetimage1` = '$fleetimage1' WHERE `fleetref` = '$ref' LIMIT 1"); } else if ($image == "2"){ $query = sprintf("UPDATE `fleet` SET `fleetimage2` = '$fleetimage2' WHERE `fleetref` = '$ref' LIMIT 1"); } else if ($image == "3"){ $query = sprintf("UPDATE `fleet` SET `fleetimage3` = '$fleetimage3' WHERE `fleetref` = '$ref' LIMIT 1"); } else if ($image == "4"){ $query = sprintf("UPDATE `fleet` SET `fleetimage4` = '$fleetimage4' WHERE `fleetref` = '$ref' LIMIT 1"); } #execute SQL statement echo "before exe"; mysql_select_db($db, $cid); $result = mysql_query($query, $cid) or die($query."<br>".mysql_error()); echo "after exe"; # check for error if (!$result){ echo("ERROR: " . mysql_error() . "\n$SQL\n"); }} else { //header("location:fleet_edit.php?ref=$ref"); //exit(); } ?>
  12. There are hundreds available, I will look on my PC when I get home and post it up if I find it.
  13. I would use a different script that uses Sessions, they are much easier to work with and more secure. I have a great script that I use that was really easy to implement and modify to my needs. I can't remember exactly where I got it but found it searching on Google. Hope this helps.
  14. Hi, thanks for your reply but I get two warnings now and still the same result, the field in the table still doesn't update? Thanks
  15. Hi all, I have a script that is supposed to upload an image and then update a field in the table with the image's path in it. The image uploads okay but the details do not UPDATE in the table... any ideas? I have echoed after the sql statement which doesn't appear upon submitting but it shows the query printed out doing the right thing (I think) <?php $ref = (!empty($_GET['ref']))?trim($_GET['ref']):""; $image = (!empty($_GET['image']))?trim($_GET['image']):""; $idir = "../fleet/"; // Path To Images Directory if (isset ($_FILES['fupload'])){ //upload the image to tmp directory $url = $_FILES['fupload']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload']['type'] == "image/jpg" || $_FILES['fupload']['type'] == "image/jpeg" || $_FILES['fupload']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload']['tmp_name'], "$idir" . $_FILES['fupload']['name']); // Move Image From Temporary Location To Permanent Location } } if (isset($_POST['submit'])){ //$fleetref=$_POST["fleetref"]; $fleetimage1 = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); $fleetimage2 = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); $fleetimage3 = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); $fleetimage4 = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); # setup SQL statement if ($image == "1") { $query = sprintf("UPDATE `fleet` SET `fleetimage1` = '$fleetimage1' WHERE `fleetref` = '$ref' LIMIT 1"); } else if ($image == "2"){ $query = sprintf("UPDATE `fleet` SET `fleetimage2` = '$fleetimage2' WHERE `fleetref` = '$ref' LIMIT 1"); } else if ($image == "3"){ $query = sprintf("UPDATE `fleet` SET `fleetimage3` = '$fleetimage3' WHERE `fleetref` = '$ref' LIMIT 1"); } else if ($image == "4"){ $query = sprintf("UPDATE `fleet` SET `fleetimage4` = '$fleetimage4' WHERE `fleetref` = '$ref' LIMIT 1"); } #execute SQL statement echo "before exe"; $result = mysql_db_query($db,$query,$cid) or die($query."<br>".mysql_error()); echo "after exe"; # check for error if (!$result){ echo("ERROR: " . mysql_error() . "\n$SQL\n"); }} ?> <div class="controls_left"> <FORM NAME="fa" ACTION="<?php echo "fleet_edit_image.php?ref=$ref&image=$image"; ?>" METHOD="POST" enctype="multipart/form-data"> <input type = "hidden" name="MAX_FILE_SIZE" value = "1000000"> Select image: <input type = "file" name = "fupload"> <p>Copyright note: Please only use photographs either that you have taken yourself or that you have permission to use as we will not be held responsible for any Copyright infringement.</p> <input name="submit" type="submit" value="Edit image" /> </FORM> </div> <div class="image_right"><?php if ($image == "1") { $imageprint = "$fleetimage1"; } else if ($image == "2") { $imageprint = "$fleetimage2"; } else if ($image == "3") { $imageprint = "$fleetimage3"; } else if ($image == "4") { $imageprint = "$fleetimage4"; } echo "<div class=\"image_right\"><img src=\"../$imageprint\" alt=\"Edit image\" width=\"293\" height=\"218\"></div>"; ?>
  16. I thought that may be the case, I think I will rearrange how my searchtags string is structured rather than go with the FULLTEXT option, it looks a little out of my depth and a lot of work for such a small thing. Thanks anyway for your reply.
  17. Hi all, a have a small problem with my search script. At the moment I am searching a field in my tabel called searchtags, now if I enter a one word search term of a string of characters it will return the results but if they are not in the same order it won't. Example: searchtags contains - Ford Mondeo 1999 2.0L petrol car If I search "Ford Mondeo" the query returns results, whereas if I search "Mondeo Ford" the query returns no results? I assume I have to expand the search in some way but I don;t know how, any ideas? Thanks in advance <?php // Get the search variable from URL $var = @$_GET['q'] ; $field = @$_GET['field'] ; $trimmed = trim($var); //trim whitespace from the stored variable if ($field == "") { //if search from homepage start here $query = "select * from fleet where searchtags like \"%$trimmed%\" order by fleetref"; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); $limit=10000; if ($numrows == 0) { echo "<p>Sorry, your search: "" . $trimmed . "" motorhomes to hire returned zero results</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<h1>You searched for - " . $var . "cars</h1>"; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $fleetref = $row['fleetref']; $fleetmake = $row['fleetmake']; $fleetmodel = $row['fleetmodel']; $fleetyear = $row['fleetyear']; $fleetchassis = $row['fleetchassis']; $fleetberth = $row['fleetberth']; $fleetlayout = $row['fleetlayout']; $fleetlength = $row['fleetlength']; $fleettype = $row['fleettype']; $fleetof = $row['fleetof']; $fleetimage1 = $row['fleetimage1']; $fleetimage2 = $row['fleetimage2']; $fleetimage3 = $row['fleetimage3']; $fleetimage4 = $row['fleetimage4']; $fleetadded = $row['fleetadded']; $fleetengine = $row['fleetengine']; $pricelow = $row['pricelow']; $pricemid = $row['pricemid']; $pricehigh = $row['pricehigh']; $fleetviews = $row['fleetviews']; $query = mysql_query("SELECT * FROM mhhire WHERE `ref` = '$fleetof'"); if(mysql_num_rows($query)==0){ echo "<p>This company does not exsist</p>"; }else{ while($details = mysql_fetch_array($query)){ $company = $details ['company']; $location = $details ['location']; echo "<div class=\"fleet_vehicle\">"; if ($fleetimage1 == "fleet/") { echo "<img src=\"images/no_image.jpg\" alt=\"$fleetmake $fleetmodel\" width=\"100\" height=\"75\" class=\"fleet_thumb\">"; } else { echo "<img src=\"$fleetimage1\" alt=\"$fleetmake $fleetmodel\" width=\"100\" height=\"75\" class=\"fleet_thumb\">"; } echo "<div class=\"fleet_title\">$fleetmake $fleetmodel $fleetyear</div>"; echo "<div class=\"fleet_berth\"><img src=\"images/$fleetberth.gif\" alt=\"$fleetberth berth\"></div>"; echo "<div class=\"fleet_details_in\"><div class=\"fleet_details\">- $fleetberth berth<br />- $fleetlayout<br /></div></div>"; echo "<div class=\"fleet_details_in\"><div class=\"fleet_details\">- $fleetchassis<br />- $fleetengine<br /></div></div>"; echo "<div class=\"fleet_details_in\"><div class=\"fleet_details\">- $fleetlength meters<br />- $fleettype<br /></div></div>"; echo "<div class=\"fleet_options\">From <strong>$company</strong> in <strong>$location</strong> - <a href=\"view_motorhome_for_hire.php?ref=$fleetref\">More info >></a></div>"; echo "</div>"; }} } } ?>
  18. Thanks for your help. I thought it would be something simple
  19. Sorry, it is defined at the top of the page $account = $_SESSION['SESS_ACCOUNT'];
  20. HTML Form <FORM NAME="fa" ACTION="fleet_edit.php" METHOD="POST" enctype="multipart/form-data"> <div class="input_row"><div class="input_titles">Make:</div> <div class="input_box"> <INPUT NAME="fleetmake" TYPE="text" id="fleetmake" VALUE="<?php echo $fleetmake; ?>" SIZE=15> e.g. Swift </div> </div> <div class="input_row"><div class="input_titles">Model:</div><div class="input_box"><INPUT NAME="fleetmodel" TYPE="text" id="fleetmodel" VALUE="<?php echo $fleetmodel; ?>" SIZE=15> e.g. Kon-Tiki 669 </div> </div> <div class="input_row"><div class="input_titles">Year:</div><div class="input_box"><input name="fleetyear" type="text" id="fleetyear" value="<?php echo $fleetyear; ?>" size="4" /> What year was the vehicle manufactured?</div> </div> <div class="input_row"><div class="input_titles">Berth:</div><div class="input_box"><select name="fleetberth" id="fleetberth"> <option selected="selected"><?php echo $fleetberth; ?><option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> </select> What is the maximum sleeping capacity of the vehicle? </div> </div> <div class="input_row"> <div class="input_titles">Shipping length </div> <div class="input_box"><input name="fleetlength" type="text" id="fleetlength" value="<?php echo $fleetlength; ?>" size="6" /> Please provide measurement in METERS </div> </div> <div class="input_row"> <div class="input_titles">Chassis</div> <div class="input_box"><input name="fleetchassis" type="text" id="fleetchassis" value="<?php echo $fleetchassis; ?>" size="15" /> e.g. Fiat </div> </div> <div class="input_row"> <div class="input_titles">Engine size </div> <div class="input_box"><input name="fleetengine" type="text" id="fleetengine" value="<?php echo $fleetengine; ?>" size="15" /> e.g. 3.0TD </div> </div> <div class="input_row"><div class="input_titles">Layout:</div><div class="input_box"><select name="fleetlayout" id="fleetlayout"> <option selected="selected"><?php echo $fleetlayout; ?><option> <option>Fixed bed</option> <option>Fixed bunk beds</option> <option>End lounge</option> <option>End washroom</option> <option>End kitchen</option> </select> What is the sleeping capacity of the vehicle? </div> </div> <div class="input_row"> <div class="input_titles">Vehicle type :</div> <div class="input_box"><select name="fleettype" id="fleettype"> <option selected="selected"><?php echo $fleettype; ?><option> <option>Coachbuilt low line</option> <option>Coachbuilt high line</option> <option>Van conversion</option> <option>A Class</option> <option>Camper van</option> <option>American RV</option> </select> What is the vehicle type?</div> </div> <div class="input_row"><div class="input_titles">Description:<br /><br /> (Use this space to add anything you wish to say about the vehicle)</div> <div class="input_box"><textarea name="fleetcomments" cols="50" rows="10" id="fleetcomments" type="text" value="" /><?php echo $fleetcomments; ?></textarea></div></div> <div class="input_row"> <div class="input_titles">Price low season:</div> <div class="input_box"><input name="pricelow" type="text" id="pricelow" value="<?php echo $pricelow; ?>" size="10" /> Provide price per week </div> </div> <div class="input_row"> <div class="input_titles">Price mid season:</div> <div class="input_box"><input name="pricemid" type="text" id="pricemid" value="<?php echo $pricemid; ?>" size="10" /> Provide price per week </div> </div> <div class="input_row"> <div class="input_titles">Price high season:</div> <div class="input_box"><input name="pricehigh" type="text" id="pricehigh" value="<?php echo $pricehigh; ?>" size="10" /> Provide price per week </div> </div> <div class="input_row">Please note: upon cilcking "edit fleet vehicle" any changes you have made above will be made to your live listing for this particular vehicle. <br /> <br /> </div> <div class="input_row"><div class="input_titles"><input name="submit" type="submit" value="Edit fleet vehicle" /> </div></div> </FORM>
  21. Hi all, I am having difficulty getting my UPDATE script to work. Basically the info is being pulled from a form and then being UPDATED, but it doesn't actually update and I am presented with no errors. It finds the record correctly and displays in the fields in the form as it should, just no update! Any ideas? Thanks in advance... <?php error_reporting (E_ALL ^ E_NOTICE); $usr = "fdgdg"; $pwd = "dgdg"; $db = "dgdg"; $host = "dgdg.ddg.dg.50dgdg /***********************Get Record***********************/ $ref = (!empty($_GET['ref']))?trim($_GET['ref']):""; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid){ echo("ERROR: " . mysql_error() . "\n"); } $db_selected = mysql_select_db(database, $cid); $query = sprintf("SELECT * FROM fleet where fleetref like '%s' LIMIT 1","%".mysql_real_escape_string($ref)."%"); $result = mysql_query($query) or die($query."<br>".mysql_error()); $record = mysql_fetch_assoc($result); if(mysql_num_rows($result) > 0) { echo "<strong>Updating fleet vehicle</strong>"; $fleetref=$record["ref"]; $fleetmake=$record["fleetmake"]; $fleetmodel=$record["fleetmodel"]; $fleetberth=$record["fleetberth"]; $fleetyear=$record["fleetyear"]; $fleetlength=$record["fleetlength"]; $fleetchassis=$record["fleetchassis"]; $fleetengine=$record["fleetengine"]; $fleetlayout=$record["fleetlayout"]; $fleettype=$record["fleettype"]; $fleetcomments=$record["fleetcomments"]; $pricelow=$record["pricelow"]; $pricemid=$record["pricemid"]; $pricehigh=$record["pricehigh"]; $fleetof=$record["fleetof"]; }else{ echo "<div id=\"pages\"><strong>Record not found</strong> - Edit Directory</div>"; $fleetmake=""; $fleetmodel=""; $fleetberth=""; $fleetyear=""; $fleetlength=""; $fleetchassis=""; $fleetengine=""; $fleetlayout=""; $fleettype=""; $fleetcomments=""; $pricelow=""; $pricemid=""; $pricehigh=""; $fleetof=$record["fleetof"]; } if ($fleetof == $account) { /***********************Save Record***********************/ # this is processed when the form is submitted # back on to this page (POST METHOD) if (isset($_POST['submit'])){ $fleetmake=$_POST["fleetmake"]; $fleetmodel=$_POST["fleetmodel"]; $fleetberth=$_POST["fleetberth"]; $fleetyear=$_POST["fleetyear"]; $fleetchassis=$_POST["fleetchassis"]; $fleetengine=$_POST["fleetengine"]; $fleetlayout=$_POST["fleetlayout"]; $fleetlength=$_POST["fleetlength"]; $fleettype=$_POST["fleettype"]; $fleetcomments=$_POST["fleetcomments"]; $pricelow=$_POST["pricelow"]; $pricemid=$_POST["pricemid"]; $pricehigh=$_POST["pricehigh"]; # setup SQL statement $query = sprintf("UPDATE `fleet` SET `fleetmake` = '%s',`fleetmodel` = '%s',`fleetberth` = '%s',`fleetyear` = '%s',`fleetchassis` = '%s',`fleetengine` = '%s',`fleetlayout` = '%s',`fleetlength` = '%s',`fleettype` = '%s',`fleetcomments` = '%s',`pricelow` = '%s',`pricemid` = '%s',`pricehigh` = '%s' WHERE `fleetref` ='%s' LIMIT 1", mysql_real_escape_string($fleetmake),mysql_real_escape_string($fleetmodel),mysql_real_escape_string($fleetberth),mysql_real_escape_string($fleetyear),mysql_real_escape_string($fleetchassis),mysql_real_escape_string($fleetengine),mysql_real_escape_string($fleetlayout),mysql_real_escape_string($fleetlength),mysql_real_escape_string($fleettype),mysql_real_escape_string($fleetcomments),mysql_real_escape_string($pricelow),mysql_real_escape_string($pricemid),mysql_real_escape_string($pricehigh),mysql_real_escape_string($fleetref)); #execute SQL statement $result = mysql_db_query($db,$query,$cid) or die($query."<br>".mysql_error()); # check for error if (!$result){ echo("ERROR: " . mysql_error() . "\n$SQL\n"); } echo "<P>Fleet vehicle updated</P>\n"; } } else {echo "Sorry, you are not authorised to edit this vehicle, please contact the system administrator for further help.";} ?>
  22. Hi, thanks for taking the time to help me out. It works when saving the image in the folder, but when I am inserting the data into my table I used 'name' and it is inserting the images original name if that makes sense? [code=php:0]$logo = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); [/code]
  23. Hi all! I have a problem with an image uploading script and at the moment it keeps the image name the same, obviously people don't have very adventurous names for their images "image1" and they are over writing each other. How do I put a random 5 digit number on the end to make them all unique? Thanks. $image1 = mysql_real_escape_string("$idir" . $_FILES['fupload2']['name']); $image2 = mysql_real_escape_string("$idir" . $_FILES['fupload3']['name']); $image3 = mysql_real_escape_string("$idir" . $_FILES['fupload4']['name']); $logo = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); $idir = "uploads/"; // Path To Images Directory if (isset ($_FILES['fupload'])){ //upload the image to tmp directory $url = $_FILES['fupload']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload']['type'] == "image/jpg" || $_FILES['fupload']['type'] == "image/jpeg" || $_FILES['fupload']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload']['tmp_name'], "$idir" . $_FILES['fupload']['name']); // Move Image From Temporary Location To Permanent Location } } if (isset ($_FILES['fupload2'])){ //upload the image to tmp directory $url = $_FILES['fupload2']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload2']['type'] == "image/jpg" || $_FILES['fupload2']['type'] == "image/jpeg" || $_FILES['fupload2']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload2']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload2']['tmp_name'], "$idir" . $_FILES['fupload2']['name']); // Move Image From Temporary Location To Permanent Location } } if (isset ($_FILES['fupload3'])){ //upload the image to tmp directory $url = $_FILES['fupload3']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload3']['type'] == "image/jpg" || $_FILES['fupload3']['type'] == "image/jpeg" || $_FILES['fupload3']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload3']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload3']['tmp_name'], "$idir" . $_FILES['fupload3']['name']); // Move Image From Temporary Location To Permanent Location } } if (isset ($_FILES['fupload4'])){ //upload the image to tmp directory $url = $_FILES['fupload4']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload4']['type'] == "image/jpg" || $_FILES['fupload4']['type'] == "image/jpeg" || $_FILES['fupload4']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload4']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload4']['tmp_name'], "$idir" . $_FILES['fupload4']['name']); // Move Image From Temporary Location To Permanent Location } }
  24. Hi solved it, thanks anyway everyone! Was because I hadn't changed my hosting from Windows to Linux! SORRY
×
×
  • 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.