Jump to content

glassfish

Members
  • Posts

    119
  • Joined

  • Last visited

Everything posted by glassfish

  1. Does anybody know a good tutorial for creating thumbnails for these three file extensions "jpg, gif and png" in PHP? I am only finding ones for "jpg".
  2. Okey, thanks guys, it worked. And now, here, at this spot : while($row = mysql_fetch_array($result)) { $photo_category_list .= <<<__HTML_END <option value="$row[0]">$row[1]</option>n __HTML_END; } I get the following error: Notice: Undefined variable: photo_category_list in C:\xampp\htdocs\sitepoint\preupload.php on line 26 I am not getting an error for the other variable "$photo_upload_fields". Why do I get an error for this variable? EDIT: Sorry, I totally missed it. It may happen because the database is empty.
  3. I am getting this error message: Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\sitepoint\preupload.php on line 67 with this script: <?php include 'config.inc.php'; // initialization $photo_upload_fields = ''; $counter = 1; // If we want more fields, then use, preupload.php?number_of_fields=20 $number_of_fields = (isset($_GET['number_of_fields'])) ? (int)($_GET['number_of_fields']) : 5; // Firstly Lets build the Category List $result = mysql_query('SELECT category_id,category_name FROM gallery_category'); while($row = mysql_fetch_array($result)) { $photo_category_list .= <<<__HTML_END <option value="$row[0]">$row[1]</option>n __HTML_END; } mysql_free_result( $result ); // Lets build the Image Uploading fields while($counter <= $number_of_fields) { $photo_upload_fields .= <<<__HTML_END <tr><td> Photo {$counter}: <input name="photo_filename[]" type="file" /> </td></tr> <tr><td> Caption: <textarea name="photo_caption[]" cols="30" rows="1"></textarea> </td></tr> __HTML_END; $counter++; } // Final Output echo <<<__HTML_END <html> <head> <title>Lets upload Photos</title> </head> <body> <form enctype="multipart/form-data" action="upload.php" method="post" name="upload_form"> <table width="90%" border="0" align="center" style="width: 90%;"> <tr><td> Select Category <select name="category"> $photo_category_list </select> </td></tr> <! - Insert the image fields here --> $photo_upload_fields <tr><td> <input type="submit" name="submit" value="Add Photos" /> </td></tr> </table> </form> </body> </html> __HTML_END; ?> on line 67 It points to the closing tag: ?> Does anybody have a suggestion how to solve this issue?
  4. It also is a "how to do it" question, I was looking for pointers.
  5. It has been Object Oriented Programming itself. I was wondering "how it would look like" when looking to keep the code organized and separately from each other when it comes having this done with Object Oriented Programming. The above script is written in procedual style, I would "have to" build the query "into" the script. I could be looking to also write the script in Object Oriented Programming and then add the query also in Object Oriented Programming to it.
  6. I have this image upload script here: <?php if (isset($_POST['submit'])) { $j = 0; //Variable for indexing uploaded image $target_path = $_SERVER['DOCUMENT_ROOT'] . "/ubergallery/multiple_image_upload/uploads/"; //Declaring Path for uploaded images for ($i = 0; $i < count($_FILES['file']['name']); $i++) {//loop to get individual element from the array $validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) $file_extension = end($ext); //store extensions in the variable $target_path = $target_path . md5(uniqid()) . "." . $ext[count($ext) - 1];//set the target path with a new name of image $j = $j + 1;//increment the number of uploaded images according to the files in array if (($_FILES["file"]["size"][$i] < 100000) //Approx. 100kb files can be uploaded. && in_array($file_extension, $validextensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path)) {//if file moved to uploads folder echo $j. ').<span id="noerror">Image uploaded successfully!.</span><br/><br/>'; } else {//if file was not moved. echo $j. ').<span id="error">please try again!.</span><br/><br/>'; } } else {//if file size and file type was incorrect. echo $j. ').<span id="error">***Invalid file Size or Type***</span><br/><br/>'; } } } ?> This script also uses javascript for multiple uploading of images. I am looking to add a query to this where I am looking to have the image file names stored in the database. The original image file name should get stored as well, yet the file name itself should get a unique id. I may have to build this query inside this upload script. I was wondering if I can keep that separately with Object Oriented Programming, if somebody just could show me "how it could look like", when it comes to having this done with Object Oriented Programming, I would appreciate it a lot.
  7. Hey, I have really looked around and done the research on books and video tutorials about object oriented programming, though I am having difficulties to find something good which gets myself started. Could somebody recommend me a good book or video tutorials, where I could get started with when it comes to Object Oriented Programming. I am looking to use Object Oriented Programming for building a blog website.
  8. I have used $_SERVER['DOCUMENT_ROOT']; Then I have gotten a new error message: Warning: move_uploaded_file(uploads/1f77f7e78f36847859c0604e9645f112.jpg): failed to open stream: No such file or directory in C:\xampp\htdocs\ubergallery\multiple_image_upload\upload.php on line 17 Warning: move_uploaded_file(): Unable to move 'C:\xampp\tmp\phpE035.tmp' to 'uploads/1f77f7e78f36847859c0604e9645f112.jpg' in C:\xampp\htdocs\ubergallery\multiple_image_upload\upload.php on line 17 1).please try again!. I have looked for the permissions, and the folder "uploads" was set to "read-only", I have tried to "uncheck" this yet it sets itself back to "read-only" again. I am also not sure how and from where this folder gets set to "read-only". Do you have a suggestion? EDIT: Sorry, this may be a whole new question, then.
  9. When I turn "allow_url_include" to "On" then I still get the same error message. Also I was not sure if that was the issue to begin with.
  10. The Error Message: Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\xampp\htdocs\ubergallery\multiple_image_upload\multiupload.php on line 27 Warning: include(http://localhost/ubergallery/multiple_image_upload/upload.php): failed to open stream: no suitable wrapper could be found in C:\xampp\htdocs\ubergallery\multiple_image_upload\multiupload.php on line 27 Warning: include(): Failed opening 'http://localhost/ubergallery/multiple_image_upload/upload.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\ubergallery\multiple_image_upload\multiupload.php on line 27 I am getting this error message. Including a stylesheet or a jquery file with the absolute path does work out, with this I was looking to include a PHP script with the absolute path. Here is the code: <!DOCTYPE html> <html> <head> <title>Upload Multiple Images Using jquery and PHP</title> <!-------Including jQuery from google------> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="script.js"></script> <!-------Including CSS File------> <link rel="stylesheet" type="text/css" href="style.css"> <body> <div id="maindiv"> <div id="formdiv"> <h2>Multiple Image Upload Form</h2> <form enctype="multipart/form-data" action="" method="post"> First Field is Compulsory. Only JPEG,PNG,JPG Type Image Uploaded. Image Size Should Be Less Than 100KB. <hr/> <div id="filediv"><input name="file[]" type="file" id="file"/></div><br/> <input type="button" id="add_more" class="upload" value="Add More Files"/> <input type="submit" value="Upload File" name="submit" id="upload" class="upload"/> </form> <br/> <br/> <!-------Including PHP Script here------> <?php include("http://localhost/ubergallery/multiple_image_upload/upload.php"); ?> </div> <!-- Right side div --> <div id="formget"><a href=http://www.formget.com/app><img src="formget.jpg" alt="Online Form Builder"/></a> </div> </div> </body> </html> I was looking to include "upload.php" with the absolute path. Any suggestions what to do here?
  11. I was thinking of a board where you can bookmark the photos from Facebook. It may require an App and a "Facebook Login" for the website, so one can bookmark photos from Facebook. The website would have additional features for the photos. I thought of an "Add to ..." function. Is this possible with the Facebook API?
  12. Sorry if I am not quite understanding this part. Which is the "form processing code"?
  13. Is there an alert method for the MySQL database or something similar? What is the proper way to check if the MySQL database connection is working? I mean other than "creating" and "retrieving" with "insert" and "select".
  14. How to accomplish the part I have put in bold? My script is one post above this.
  15. Can you check this script please. It looks like the token id's do not match with this: I tried to echo it out and I am getting two different token ID's. Why? Example: The token ID does not match. 54340807202db 543407b9cffd4 The Script: <?php session_start(); $token_id = uniqid(); $_SESSION['token_id'] = $token_id; ?> <h1>Do Add a Message to the MySQL Database</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <textarea name="message"></textarea> <input type="hidden" name="token_id" value="<?php echo $token_id; ?>"/> <br/> <input type="submit" name="submit"/> </form> <?php // The Connection to the Database // Taken Out ?> <?php // To select the text data from the MySQL database. $tqs = "SELECT * FROM messages"; $tqr = mysqli_query($dbc, $tqs); // To print out the text data inside of table on the page. echo "<h1>This Is Where the Messages Gets Printed on Screen</h1>"; echo "<table><tr><td>ID</td><td>The Message</td></tr>"; while($row = mysqli_fetch_assoc($tqr)){ echo "<tr><td>" . $row['id'] . "</td><td>" . $row['message'] . "</td></tr>"; } echo "</table>"; ?> <?php // To insert the text data into the MySQL database. if(isset($_POST['submit']) && isset($_POST['token_id']) && isset($_SESSION['token_id'])){ if($_POST['token_id'] == $_SESSION['token_id']){ $tqs = "INSERT INTO messages (`message`) VALUES ('{$_POST['message']}')"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); }else { echo "The token ID does not match."; } }else{ echo "Is not set."; } ?>
  16. The data is already wiped off of the textarea. I think it gets added from the cache of the web browser.(?) Can you provide a link, please? I thought more people come across this issue and I was looking for a proper way to have this issue taken care of.
  17. The Script: <h1>Do Add a Message to the MySQL Database</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <textarea name="message"></textarea> <br/> <input type="submit" name="submit"/> </form> <?php // The Connection to the Database // Taken Out ?> <?php // To insert the text data into the MySQL database. if(isset($_POST['submit'])){ $tqs = "INSERT INTO messages (`message`) VALUES ('{$_POST['message']}')"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); } ?> <?php // To select the text data from the MySQL database. $tqs = "SELECT * FROM messages"; $tqr = mysqli_query($dbc, $tqs); // To print out the text data inside of table on the page. echo "<h1>This Is Where the Messages Gets Printed on Screen</h1>"; echo "<table><tr><td>ID</td><td>The Message</td></tr>"; while($row = mysqli_fetch_assoc($tqr)){ echo "<tr><td>" . $row['id'] . "</td><td>" . $row['message'] . "</td></tr>"; } echo "</table>"; ?> 1. When I have added text with the form to the MySQL database... 2. ... and I have clicked on "page reload" in Firefox to reload the page... 3. ... then the before submitted text gets submitted again to the MySQL database. So basically, add text with the form to the MySQL database, reload the page in Firefox, and the before added text will get submitted to the MySQL database again. My Question Is: What is the proper way to avoid this?
  18. Thanks for the answer. I was looking for an editor for example "Microsoft Live Writer", yet I am looking for a way to use it for my self-built blog and have the post published to it. I am not sure how the publishing would have to work with the MySQL database. I also am not sure how those editors like "Microsoft Live Writer" have their publishing work with Wordpress and similar.
  19. I have a self-built blog website, done with PHP and MySQL. How to write the posts offline? How is it done? Which tools are used? Any suggestions?
  20. I was looking to write tutorials. I am wondering if the procedual style is legitimate? Because I have been reading posts on the internet like: "horrid code" and similar, also because of issues like "SQL injection". Any suggestions on the procedual style specifically, when one is looking to write tutorials?
  21. Ohh man, I totally missed that. I apologize for this mistake. It is working now.
  22. This is my code: The Form: <div class="tcn02"> <H1>You are Writing this Post</H1> <form action="insert.php" method="POST"> <input class="input_title" type="text" name="title" /> <br /> <textarea id="editor1" type="text" name="post"></textarea> <br /> <input type="submit" name="submit" /> </form> </div> The Query: <?php $title = $_POST['title']; $post = $_POST['post']; echo "<div class='tcn02'>"; # The Query String $tqs = "INSERT INTO ttn02 (title, post, date_created) VALUES ('$title', '$post', now())"; # The Query Run $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); echo "The data has gotten successfully added."; echo "</div>"; ?> When I try to store code which I am looking to print inside pre tags, then the code gets cut off. I have tried to store the form from above into the database. Each time it gets cut off like shown in the example This is how it gets stored into the database: <p>The Code:</p> <pre> <<strong>div </strong><strong>class=</strong><strong>"tcn02"</strong>> <<strong>H1</strong>>You are Writing this Post</<strong>H1</strong>> <<strong>form </strong><strong>action=</strong><strong>"insert.php" </strong><strong>method=</strong><strong>"POST"</strong>> <<strong>input </strong><strong>class=</strong><strong>"input_title" </strong><strong>type=</strong><strong This is how it looks like when printing it: <div class="tcn02"> <H1>You are Writing this Post</H1> <form action="insert.php" method="POST"> <input class="input_title" type= What could be the problem here?
×
×
  • 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.