Jump to content

fredted40x

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Everything posted by fredted40x

  1. Solved! Found out i didnt need any " or '. echo "<img src=getoutside.php?id=$r[apartmentId]>"; worked . Thanks for helping p.s. cant find the soled button now
  2. Thanks again for replying. That line seems to work but without errors now but im still getting a white box with a cross in it. Its says the location for the image is http://localhost/webs/getoutside.php?id='".15. and if i remove the two ' it says the location is http://localhost/webs/getoutside.php?id=".15. Do you need the full stops? If i remove them they go from the url as well. It doesnt seem to be calling getoutside.php, from what i can gather it thinks that it is a image. edit: If i change src to href i get a white box with a different icon in it
  3. Are you able to check the insert code for me please. Im thinking it may either be that or the getoutside.php file. <form action="admin.php" method="post" enctype="multipart/form-data" > ... <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input name="userfile" type="file" id="userfile"> ... admin.php include 'dbase.php'; //connect to database //get file information --step1 $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; //get file content -- step1 $fp = fopen($tmpName, 'r'); $content = fread($fp, $fileSize); $content = addslashes($content); fclose($fp); $query = "INSERT INTO apartment VALUES(NULL,...,'$content')"; mysql_query($query)
  4. Ok, understand now thanks. Adding the / to make it echo "<img src=getoutside.php?id='\".$r['apartmentId']. \" '>"; gives me a unexpected T_ENCAPSED_AND_WHITESPACE error. without the \'s it now produces just a white image with an x in.
  5. can you explain please? Dont think i've used them before. Heres the code to add the image if it helps. //get file information --step1 $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; //get file content -- step1 $fp = fopen($tmpName, 'r'); $content = fread($fp, $fileSize); $content = addslashes($content); fclose($fp);
  6. Hi, I have managed to get the code working to store a .jpg file in the database under the longblob type. Now all i have left to do is to retrieve that image and display it. So far i have this: list.php while($r = mysql_fetch_array($sql)) { //for each record ... echo " <img src= getoutside.php?id='".$r[apartmentId]. " '> "; getoutside.php <?php header("Content-type: image/jpg"); // act as a jpg file to browser $nId = $_GET['id']; include 'dbase.php'; //connect to database $sqlo = "SELECT outside FROM apartment WHERE apartmentId = $nId"; $oResult = mysql_query($sqlo); $oRow = mysql_fetch_array($oResult); $sJpg = $oRow["outside"]; echo $sJpg; ?> The result from this is a box with a red cross in it. Can anyone find a problem with this code please? Thanks
  7. Would it be down to file permissions? I have just craated a test page with only the code from that link. Im not getting any errors when it submits, it just refreshes the page and doesnt upload the file. Curently im using xampp. Update: SIgnore this please, it now works on the test page.
  8. Thanks for your reply. It looks similar to one i've tried before. I found that when i add the code enctype="multipart/form-data" It no longer submits to the database. Would that be because it also has text inputs in the form as well?
  9. Hi, I have a basic form that lets people enter details <form action="welcome.php" method="post"> Name: <input type="text" name="fname" /> Second name: <input type="text" name="sname" /> <input type="submit" /> </form> And the standard insert in sql command. Im now looking to add a image uplad field the the same form. I have tried several methods off the internet but i cant get any to work. I would like the form to upload the image into the directory '../images' and then save the path to the file in the database, e.g. 'images/picture.jpg'. Can anyone point me in the right direction please. Im guessing i will have to use the file input type but i cant get any of it to work. Thanks
  10. Hi, I have a form that allows a user to enter details and also to upload a image. The form works great and inserts into the database if i dont include the file input. What i would like happen is: The user enters details and selects a file The file then gets uploaded to ../images and the path is then written to bedroom1 variable The addresses and the bedroom1 variable that now holds the uploaded file path e.g. images/test.jpg is written to the database Form <form action="admin.php" method="POST"> <table> <tr><td> Address 1: </td><td> <input type="text" name="address1" id="address1" onfocus="selected(this)" onblur="notselected(this)"> </td><td> <div id="dynamicText1"> </div> </td></tr> <tr><td> Address 2: </td><td> <input type="text" name="address2" id="address2" onfocus="selected(this)" onblur="notselected(this)"> </td><td> <div id="dynamicText1"> </div> </td></tr> <tr><td> County: </td><td> <input type="text" name="county" id="county" onfocus="selected(this)" onblur="notselected(this)"> </td><td> <div id="dynamicText1"> </div> </td></tr> <tr><td> Bedroom 1: </td><td> <input type="file" name="bedroom1" id="bedroom1" input name="uploadedfile"> </td><td> <div id="dynamicText1"> </div> </td></tr> <tr><td> <input type="submit" name="submitaddapartment" value="Add" id="registerbutton"> </td></tr> </table </form> And the php code to add it to the database <?php //get variables $submitaddapartment = $_POST['submitaddapartment']; $address1 = strip_tags($_POST['address1']); $address2 = strip_tags($_POST['address2']); $county = strip_tags($_POST['county']); $bedroom1 = strip_tags($_POST['bedroom1']); if ($submitaddapartment) //if submit button was pressed { if ($address1&&$address2&&$county&&$bedroom1&&) //if fields arn't blank { include 'dbase.php'; //connect to database if ((($_FILES["bedroom1"]["type"] == "image/gif") || ($_FILES["bedroom1"]["type"] == "image/jpg") || ($_FILES["bedroom1"]["type"] == "image/pjpeg")) && ($_FILES["bedroom1"]["size"] < 20000000)) { if ($_FILES["bedroom1"]["error"] > 0) { echo "Return Code: " . $_FILES["bedroom1"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["bedroom1"]["name"] . "<br />"; echo "Type: " . $_FILES["bedroom1"]["type"] . "<br />"; echo "Size: " . ($_FILES["bedroom1"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["bedroom1"]["tmp_name"] . "<br />"; if (file_exists("../images/" . $_FILES["bedroom1"]["name"])) { echo $_FILES["bedroom1"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["bedroom1"]["tmp_name"], "/" . $_FILES["bedroom1"]["name"]); echo "Stored in: " . "../images/" . $_FILES["bedroom1"]["name"]; $bedroom1=".'images/.' $_FILES["bedroom1"]["name"]"; } } } else { echo "Invalid file"; } mysql_query ("INSERT INTO user VALUES(NULL,'$address1','$address2','$county','$bedroom1')"); } else { } } ?> Any help would be greatly appreciated. Thanks Fred
  11. Hi, Just working on my university project, have quickly knocked up a login and register function but im now trying to create a drop down login box like twitter. It has to be written code and jquery cant be used. Is javascript the language i need? If it is can anyone point me to somewhere that could help. Thanks Fred
  12. The problem is i have only done one unit on php and java at uni so have a very basic knowledge of these. I would like a calendar that shows dates that have been booked and the date that haven't been book to show as a different colour and be clickable to a email form. Basically almost exactly like that calendar.
  13. Hi, As a part of my university course final year project i have to create a room reservation system. I have found this http://www.phpjabbers.com/availability-booking-calendar/index.php Which looks perfect but i cant use that as i have to code it myself. Does anyone know of a guide that will help me build something similar? Thanks in advance
  14. Hi, Im trying to create a really simple password protected page that is fairly secure but when the user doesnt enter a password the wrong error is displayed. Can anyone see a problem? Also could someone please check that im properly compairing the hash password of 2135fa0dd7fb99d167b420b7ff34ec98 with what the user entered when its hashed? login.php <?php session_start(); ?> <?php $submit = $_POST['submit']; $password = md5($_POST['password']); if ($submit) { if ($password) { if ($password == '2135fa0dd7fb99d167b420b7ff34ec98') { $_SESSION['user'] = logged; header('Location: page.php'); } else { header('Location: index.php?id=1'); } } else { header('Location: index.php?id=2'); } } else { header('Location: index.php?id=1'); } ?> index.php <?php $id=$_REQUEST['id']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/xml; charset=utf-8" /> <title>Keys</title> <link rel = "stylesheet" type = "text/css" href = "css/layout.css" /> </head> <body> <div id="header"> <h1>Keys</h1> </div> <div id="secondheader"> </div> <div id="main"> <form method="POST" action="login.php"> Password: <input type="password" name="password" onfocus="selected(this)" onblur="notselected(this)"> <input type="submit" name="submit" value="Login"> </form> <br/> <?php if ($id==1) { echo "Invalid password. Please try again"; } elseif ($id==2) { echo "Please enter a password"; } ?> </div> <div id="footer"> </div> <div id="left"> </div> </body> </html> Thanks in advance.
  15. Hi, Im trying to create a page that uses google maps and links that move the map to the location. e.g. if the user click 'sports hall' it will move the map to the sports hall without refreshing the page. I guess i need the ajax api but i cant incorporate it into my site as i use css and when i put the code inside a div tag the mpa doesnt show. Can anyone tell me if the ajax api will work in php and if its the one im looking for? Thanks. p.s. The following page is like what i want but without the google header etc and jsut the links and maps. http://maps.google.com/maps/ms?f=q&hl=en&geocode=&time=&date=&ttype=&ie=UTF8&om=1&msa=0&msid=114250687465160386813.00043d08ac31fe3357571&ll=32.990236,-116.732483&spn=1.105782,1.757813&z=9&source=embed&utm_campaign=en&utm_medium=lp&utm_source=en-lp-na-us-gns-gm&utm_term=CaseStudies
  16. Is it that simple. Thought i tried that a while ago. Do you have to put www.etc in or can it just be /folder1/file.doc.
  17. Hi, Just looking how to create a link to download a file located on the server, it will be files like .doc etc. Cant seem to find anything on the net so i think i need php but may be html. Can anyone point me in the right direction? Thanks p.s. it will be used for more than one file so im looking for a small ish amount of code.
  18. Hi i have this form echo ('<form method="POST" action="$page"> Username: <input type="text" name="username"> Password: <input type="password" name="password"> <input type="submit" name="submit" value="Login"> </form>'); And i would like the action of the form to be whatever is in $page. Is it possible, and how would i go about doing it? Thanks
  19. sorted, thank you for that. Feel a bit stupid now but couldnt get it to work.
  20. How do you pass though. There isnt any more code thats worth posting as its the first thing the function should so, assign a variable with that string.
  21. Hi, Im trying to call a ajax function and send a string that the ajax javascript function can use. So far i have <a href="#dd" onclick="sh()">Fly</a> And i want to send with the link a string e.g. "thanks". How can i send the string and use it in the seperate ajax file? Thanks
  22. That's great! Would have never got that. Thank you!
×
×
  • 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.