Jump to content

elviapw

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Everything posted by elviapw

  1. Where do I find out about permissions? How can I change them? Does that depend on my service provider? Thanks!!
  2. Hello! I'm trying to create a page for users to upload text and images to a MYSQL database. However, I I'd like to store only the image information in the database, but move the image itself in a folder in an image directory on the website. I hope that makes sense so far. The code I have so far is intended to store the text information in the database and upload the image directly to a folder on the website called /images. I'm having trouble getting it to work. First, here is the HTML form for the user to input the data: <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>post</title> </head> <body> POST<br/><br/> <form action="posted.php" method="post" enctype="multipart/form-data"> title:<br /> <input type="text" name="title" size="93"/> (optional)<br /> date: <br/> <input type="text" name="date" /><br/> post:<br /> <textarea rows="100" cols="80" name="post"></textarea><br /> pictures: <br/> <input type="file" name="picture" accept="image/jpeg"/> <input type="submit" name="Submit" value="do it"/><br /> </form> </body> </html> and here is the PHP file (posted.php) : <?php $target = "/images"; $target = $target . basename ($_FILES['picture']); $title = $_POST['title']; $post = $_POST['post']; $date = $_POST['date']; $picture = $_FILES['picture']; mysql_connect("--", "--", "--") or die(mysql_error()) ; mysql_select_db("dbname") or die(mysql_error()) ; mysql_query("INSERT INTO Posts (Number,Title,Content,Date,Picture) VALUES (null,'$title', '$post', '$date', '$picture')") ; if(move_uploaded_file $_FILES['picture'], $target) { echo "The file ". basename $_FILES['picture']. " has been uploaded, and your information has been added to the directory"; } else { echo "Sorry, there was a problem uploading your file."; } ?> The result is the message "I'm sorry, there was a problem uploading your file" I'm fairly sure the problem is with the $target or $_FILES variables. I know the connection to MYSQL works because I've gotten a different form to work that uploads only text to the database, but the images are posing a problem. I'm not sure I understand the basic concept for moving an image file to a remote directory. Could someone help me with the syntax? Thanks so much!
  3. I'm new to PHP and i'm creating a password-protected blog. the only page that isn't working is the "posted.php" page, which posts the information after a user has logged in. the problem with the code is in query2, because the echo "yes", which I'm using to test the query, does not print. The page should print YES, YES, and then VIEW POST; it should also add the "post" and "title" to the archive (archive.php). I don't think I'm using the right function to add the information to the database. Help! here's the code: <html> <head> <title>posted</title> </head> <body> <table> <thead>YES</thead> <tbody> <?php $title = $_REQUEST["title"]; $post = $_REQUEST["post"]; $dbh = mysqli_connect("--", "--", "--", "--"); $sql = "INSERT INTO Posts (Number,Title,Content) VALUES(null,'$title', '$post');"; $query = mysqli_query($dbh,$sql); $newpost = "SELECT Number,Title,Content FROM Posts ORDER BY Number DESC"; $query2 = mysqli_query($dbh,$newpost); if($query2) { echo "YES"; $feed = mysqli_fetch_assoc($query2); $number = $feed['Number']; $title = $feed['Title']; $post = $feed['Content']; echo"VIEW POST\n"; echo "</tbody>"; } ?> </table> </body> </html>
×
×
  • 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.