Jump to content

tracy

Members
  • Posts

    177
  • Joined

  • Last visited

    Never

Everything posted by tracy

  1. In my opinion your first consideration should how to get the data from the Access DB to the MySQL DB...once you have determined that, the actual positng of the data into a MySQL DB and associated displaying should be achievable. [quote author=RSprinkel link=topic=119049.msg487058#msg487058 date=1166413444] Hi all, I am wondering if there is a utility or a way to extract data in HTML files into php/MySQL? My scenario: I currently am a League Owner for an online N2K3 Racing League and the files that the Sim puts out is in HTML format.  I would like to be able to process this information into an MySQL database and calculate the standings and stuff.  I am currently using a League utility which all the data is stored in an Access Database that puts out the race statistics and stuff into other HTML pages and having to upload it onto the site and linking to specific HTML pages .  I would rather it go into a MySQL Database if at all possible. Thanks very much in Advance. RSprinkel [/quote]
  2. If you go to the Paypal site, there are specific instructions depending on which method you choose to accept payment.  It is pretty easy actually.  Once you have decided which method to use, your questions might be more specific and I might be able to provide more info...  [quote author=rajmohan link=topic=119053.msg487075#msg487075 date=1166417158] hai guys i am facing a new concept now actually i did paypal involvement in my site but now i am doing new concept. a person has to pay through online. i am having their unique id, email id, name, password, now they has to pay so how to give link with paypal help me [/quote]
  3. I did quite a bit of reading here.  I did not find the info I needed in a format I could use, as I am new to php. Here are the issues I'm considering: 1.  I need to use an upload form which I will attach code for at the bottom of this message.  It contains ability to load six photos. 2.  I need every photo (all jpegs) to be converted to 200x200 pixels or smaller upon upload. 3.  I need them to be stored in a file folder on the server, named in such a way that they can be identified by mysql. 4.  I need the corresponding name stored in the actual mysql database table. 5.  I can call the storage file folder virtually anything, like ______imagefile with the _____ being the table name... I will have several tables in each database so I would likely create a file for holding images for each table in the database. The info you supplied was good, it just did not seem to address all three procedures combined...resize on upload, store resized image in file and send corresponding name of thumbnail to database table... AND...can six be done at once with the same form? AND...what happens to the actual photo after it is thumbnailed?  I don't really care if it never makes it to the file, as long as the thumbnail does... Thanks.  I appreciate your help so far. Here's the table upload form so you might have an idea of what I am uploading.  It is an auto inventory display. <html> <title>Add Vehicle Form</title> <body> <form action="insert.php" method="post"> <table> <tr> <td>Stock Number:</td><td><input type="text" name="stock" /></td> </tr> <td>Year:</td><td><input type="text" name="year" /></td> </tr> <td>Make:</td><td><input type="text" name="make" /></td> </tr> <td>Model:</td><td><input type="text" name="model" /></td> </tr> <td>Price:</td><td><input type="text" name="price" /></td> </tr> <td>Miles:</td><td><input type="text" name="miles" /></td> </tr> <td>Photo1:</td><td><input type="file" name="photo1" /></td> </tr> <td>Photo2:</td><td><input type="file" name="photo2" /></td> </tr> <td>Photo3:</td><td><input type="file" name="photo3" /></td> </tr> <td>Photo4:</td><td><input type="file" name="photo4" /></td> </tr> <td>Photo5:</td><td><input type="file" name="photo5" /></td> </tr> <td>Photo61:</td><td><input type="file" name="photo6" /></td> </tr> <input type="submit" /> </form> </body> </html> [quote author=SemiApocalyptic link=topic=118784.msg485667#msg485667 date=1166214148] As far as uploading files, the manual has a good example that can be found here: [url=http://uk2.php.net/manual/en/features.file-upload.php]Chapter 38. Handling file uploads[/url] The file name is stored in the $_FILES['fieldname']['name'] variable, you can insert that into your database if you maintain the files original name. Resizing an image can be done with the function [url=http://uk2.php.net/manual/en/function.imagecopyresampled.php]imagecopyresampled()[/url] - There is also a good example of its use on that manual page. (Assuming you have GDLib installed on the server / enabled in your php.ini) [/quote]
  4. Thanks...reviewing now...I appreciate it.
  5. I don't want the images in the database...I want the images in a file folder and the name of the image in the database, for speed. I can upload images to the database, no problem.  My current code does that.  It just slows everything to a crawl. I now want info on how to upload the picture file to a folder (resizing it to 200x200pixels on the way up) and reference said file in the database... Any info on exactly how to do that is appreciated...or tutorial that actually works...or sample code that works...I could alter. Thanks again.
  6. Exactly...name of the file in the DB, actual file in a folder...thanks.
  7. Does anyone know of a good tutorial on uploading a picture file to a folder using php and copying the name to the database in mysql?  Resizing photos on upload is helpful also...If you know it works...some I have tried do not work. Not asking for someone to write code for me but info or tutorial would be nice.  Or maybe a code that has worked for you that is similar that I could learn from and edit... I can upload the actual photo into the database but it slows it way down.  I have heard of loading the name only and resizing the photo and sending the actual photo to a file folder on the server.  The few codes I have tried were not successful.  Thanks for any guidance.  I appreciate it.
  8. I installed Apache on my PC so I could install PHP and MySQL and run scripts to test them offline... When I installed Apached, it seemed fine, it is there, etc... When I installed PHP and located the PHP folder in the Program Files, the only thing in PHP is the license text file...nothing else... Is this normal?  How do I even test it or run it or run a script...? Thanks.
  9. any thoughts on my updated question, first in thread?  Thanks...for all your help... [quote author=timmah1 link=topic=118473.msg484181#msg484181 date=1166032090] Sorry about the url, this is the exact script that I use on my site (fotobins.com) Your gettting an error on line 26 because of the url, just take it out [code] if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "Succesful Upload!"; } else [/code] [/quote]
  10. Any thoughts are appreciated on this.  Thanks.
  11. I'm only using jpeg...so if that would work I'm happy to see the code and try to modify it to work...thanks. [quote author=blacknight link=topic=118473.msg484123#msg484123 date=1166025276] all that you have asked is possable using gd support to resize the image but gd only support some file types not all i think can post a script i use and you can alter it if you want [/quote]
  12. Okee dokee... As stated earlier, this is the insert file that does not have the features I would like...such as pictures uploaded to file folders instead of the database, picture resizing on upload... So I guess the main issue now is that I would like info regarding how to send the picture itself into a file folder and the name of said picture into the database table...I think I can figure out the rest...or already have... It seems like the code would be simple but everything I have tried won't work...thoughts are apprecaited.  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Done...</title> </head> <body> <p> <?php //This is the correct code for inserting the data--the actual insertion via php-- //this is the connection to the database file include "link.php"; $sql = "INSERT INTO `inventory` (`stock`, `year`, `make`, `model`, `price`, `miles`, `photo1`, `photo2`, `photo3`, `photo4`, `photo5`, `photo6`, `description`) VALUES ('".mysql_real_escape_string($_POST['stock'])."','".mysql_real_escape_string($_POST['year'])."','".mysql_real_escape_string($_POST['make'])."','".mysql_real_escape_string($_POST['model'])."','".mysql_real_escape_string($_POST['price'])."','".mysql_real_escape_string($_POST['miles'])."','".mysql_real_escape_string($_POST['photo1'])."','".mysql_real_escape_string($_POST['photo2'])."','".mysql_real_escape_string($_POST['photo3'])."','".mysql_real_escape_string($_POST['photo4'])."','".mysql_real_escape_string($_POST['photo5'])."','".mysql_real_escape_string($_POST['photo6'])."','".mysql_real_escape_string($_POST['description'])."')"; if($res = mysql_query($sql)) { echo('one record added'); } else { echo('There was a problem inserting data.'); } ?> </body> </html> [quote author=DeathStar link=topic=118473.msg484799#msg484799 date=1166106320] First time i see an upload script!! LOL [/quote]
  13. So... I can insert a file (photo file) into the database, no problem.  I would like to see a demo of how to send the picture to a file folder, not the database...and the NAME of the photo in the database... The associated issue is:  how do I resize the photo (jpeg) when uploading to the file so that all photos are stored as 200x200 pixels, for example.  That way, if there is an issue, it is noticed on upload, not download later... Also, since each photo (six per stock number) is stored in a database with its name in a different cell in the database table, the stock association is no longer an issue...I kind of overthought that...thanks... Any thoughts on the remaining problem are appreciated...Thanks!
  14. I'd be appreciative to see the code.  Thanks. [quote author=blacknight link=topic=118473.msg484123#msg484123 date=1166025276] all that you have asked is possable using gd support to resize the image but gd only support some file types not all i think can post a script i use and you can alter it if you want [/quote]
  15. What is the fotobins url about? Also, this one has an error also.  Line 26 Also, I don't need any comment area, but thanks anyway. I feel like if I can get one of these to work I can alter it to add the five other photos... I changed my connection file to the correct one, added the php tags and changed the image folder to the correct one...no go... Thanks... [quote author=timmah1 link=topic=118473.msg484163#msg484163 date=1166030706] Sorry, I gave you the wrong thing. This works with one upload, I'm sure it can be re-configured to do more than one. Also, As long as your passing the the stock number to a database, you can associate every picture you want with the stock number. FORM [code] <form enctype="multipart/form-data" action="insert.php" method="POST"> <table> <tr> <td>Please choose a file: </td> <td><input name="uploaded" type="file" /></td> </tr> <tr>   <td>Caption (optional)</td>   <td><input name="caption" type="text" /></td> </tr> <tr> <td>&nbsp;</td> <td><? $button_text = array('Upload It','Are you sure you want to upload THAT picture?','Oh Man, that\'s going to be a good one!'); echo '<input type="submit" name="submit" value="' . $button_text[array_rand($button_text)] . '">'; ?> </td> </tr> </table> </form> [/code] INSERT [code] //This function separates the extension from the rest of the file name and returns it function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } //This applies the function to our file $ext = findexts ($_FILES['uploaded']['name']) ;     //This line assigns a random number to a variable. You could also use a timestamp here if you prefer.     $ran = rand () ;     //This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended.     $ran2 = $ran.".";     //This assigns the subdirectory you want to save into... make sure it exists!     $target = "/your/directory/images1/";     //This combines the directory, the random file name, and the extension     $target = $target . $ran2.$ext; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "<img src='http://www.fotobins.com/$username/$ran2$ext' width='100'><BR/> <a href=http://www.fotobins.com/upload.php>Upload Another Photo</a>"; } else { echo "Sorry, there was a problem uploading your file."; } include ("conncet"); $query="insert into photos (id,username,file,caption,share) VALUES ('$id','$username','$ran2$ext','$caption','No')"; $result = MYSQL_QUERY($query); [/code] [/quote]
  16. It keeps actually changing the number on line 11 of insert.php and causing an error... From $random_digit to 897656 for example and causing an error... like it's rewriting the php for insert.php. This is a single file upload also...I just wanted to see if it worked.  I can't get it to work yet... Thoughts? Also, this adds only one photo...any way to add six at a time and have them all load and be associated with the same stock number?
  17. I am able to send photos into the database table, no problem.  I guess now I would like info regarding how to send the actual picture file into a file folder on the server while sending the name of that same picture into the database table cell.  I think I can figure out the rest if I can get some guidance on how to approach this.  There are several (six) photos per stock number but may be as few as no photos per stock number.  It is basically an auto inventory listed online with photos... Here is the latest insert code I have been trying to get to work...and get errors on line 22.. // insert.php Warning: Invalid argument supplied for foreach() in /home/inv/public_html/insert.php on line // insert.php <?php //+------------------------------------------------------------------------------------------- //| Check there are files to upload //+------------------------------------------------------------------------------------------- $stockid = $_POST['stockid']; $stock = $_POST['stock']; $year = $_POST['year']; $make = $_POST['make']; $model = $_POST['model']; $price = $_POST['price']; $miles = $_POST['miles']; // You should do some validation here - look at the PHP String functions. $files = $_FILES['files']; $total_photos = 0; $uploaded = 0; foreach ($files['name'] as $key => $name) {     if ( ! empty($files['name'][$key]))     {         $total_photos++;     } } if ($total_photos > 0) {     //+-------------------------------------------------------------------------------------------     //| File Upload     //+-------------------------------------------------------------------------------------------     $path_to_photo_folder = '/home/username/public_html/uploads/photos/';     $uploaded = 0;     // TRY TO CREATE THE DIRECTORY (INCASE IT DOESN'T YET EXIST) ...     $oldumask = umask(0);     @ mkdir("$path_to_photo_folder",0777);     umask($oldumask);     foreach ($files['name'] as $key => $name)     {        $location = $path_to_photo_folder.$name.'.jpg';           if ($files['size'][$key])         {             // If you want, you can allow only certain file-types             if ($files['type'][$key] != 'image/jpeg' xor $files['type'][$key] != 'image/pjpeg' xor $files['type'][$key] != 'image/jpg')             {                 // $feedback_msg = 'Only jpeg files are allowed to be uploaded!';                 // echo $feedback_msg;                 // exit;             }             // If you want, you can set a file size limit (in bytes)             if ($files['size'][$key] > 500000)             {                 // $feedback_msg = 'The size of each file must be less than 500kb.';                 // echo $feedback_msg;                 // exit;             }                if (is_uploaded_file($files['tmp_name'][$key]))             {                 // This is the actual upload                 if ( ! @ move_uploaded_file($files['tmp_name'][$key], $location))                 {                     // $feedback_msg = 'Problem: Could not move file to destination directory.';                     // echo $feedback_msg;                     // exit;                 }                 else                 {                      $uploaded++;                      //+--------------------------------------------------------------------------                      //| Duplicate image and create a thumbnail                      //+--------------------------------------------------------------------------                      $size = getimagesize($location);                      $width = $size[0];                      $height = $size[1];                      $src = imagecreatefromjpeg($location);                      $dst = imagecreatetruecolor(200,200);                      imagecopyresized($dst, $src, 0, 0, 0, 0, 200, 200, $width, $height); // You will lose parts of the image if it has a different aspect ratio than 1:1                      imagejpeg($dst, "$path_to_file"."preview_$name.jpg", 85);                      imagedestroy($dst);                      //+--------------------------------------------------------------------------                      //| Database Insert                      //+--------------------------------------------------------------------------                      function quote_smart($value)                      {                            // This function requires an active database connection to work...                            if ( get_magic_quotes_gpc() )                            {                                $value = stripslashes($value);                            }                            // Quote if not a number or a numeric string                         if ( ! is_numeric( $value ) || $value[0]=='0')                            {                                $value = mysql_real_escape_string($value);                            }                            else                            {                                return ( int ) $value;                            }                           return $value;                      }                      if ( ! ($conn = mysql_connect('localhost', 'db_username', 'db_password')))                      {                           // $feedback_msg = 'mysql_errno() . ' ' . mysql_error();                           // echo $feedback_msg;                           // exit;                      }                      else                      {                          mysql_select_db('database_name', $conn);                          //+-------------------------------------------------                          //| Protect from SQL injection                          //+-------------------------------------------------                          $stockid = quote_smart($stockid);                          $stock = quote_smart($stock);                          $year = quote_smart($year);                          $make = quote_smart($make);                          $model = quote_smart($model);                          $price = quote_smart($price);                          $miles = quote_smart($miles);                          // Insert / Update ???                          // $sql = "INSERT INTO inventory (stock, year, make, model, price, miles, photo{$uploaded}) VALUES ($stock, $year, $make, $model, $price, $miles, $location)";                          // $sql = "UPDATE inventory SET stock=$stock, year=$year, make=$make, model=$model, price=$price, miles=$miles, photo{$uploaded}=$location WHERE id = $stockid";                         if ( ! $res = mysql_query($sql))                         {                             echo "Could not update stock# $stock<br>SQL: $sql<br> Error: ".mysql_error();                         }                         else                         {                             echo "Stock# $stock Sucessfully updated<br>";                         }                      }                  }               }         }     }     $uploaded > 1 ? $suffix = 'images were' : $suffix = 'image was';     echo "$uploaded $suffix uploaded successfully.";     echo 'Click <a href="stockmanage.php">HERE</a> to return to stock list</p>'; } ?> 
  18. I don't really have to store the photo in the database, and I think I'd be better off if I did not store it there, only the link.  That's what I'm confused about.  Where should I store the photo?  Simply in a file called photos, for example?  Then if it's in the same directory as the php code that 'calls' it, it works...
  19. Would you explain the 'database holds the link to the file' part?  I thought the database would hold the photo file, much like it holds other data.  I want to display using several sizes.  Is there a better method? I guess to answer your question, yes, the photo1 cell holds the file I uploaded for the photo...thanks. [quote author=Cagecrawler link=topic=118457.msg484049#msg484049 date=1166017510] Presuming you want the photo where $photo1 is, and assuming that the database holds the link to the photo, this is what you need: <img src=$photo1 alt=$model> [code]<?php echo (" <tr> <td> <font face=Arial>".$stock."</font> </td> <td> <font face=Arial>".$year."</font> </td> <td> <font face=Arial>".$make."</font> </td> <td> <font face=Arial>".$model."</font> </td> <td> <font face=Arial>".$price."</font> </td> <td> <font face=Arial>".$miles."</font> </td> <td> <font face=Arial><img src=".$photo1." alt=".$model."> </font> </td> </tr> "); ?>[/code] [/quote]
  20. I use this code to insert the file: <html> <title>Add Vehicle Form</title> <body> <form action="insert.php" method="post"> <table> <tr> <td>Stock Number:</td><td><input type="varchar" name="stock" /></td> </tr> <td>Year:</td><td><input type="tinyint" name="year" /></td> </tr> <td>Make:</td><td><input type="text" name="make" /></td> </tr> <td>Model:</td><td><input type="varchar" name="model" /></td> </tr> <td>Price:</td><td><input type="tinyint" name="price" /></td> </tr> <td>Miles:</td><td><input type="tinyint" name="miles" /></td> </tr> <td>Photo1:</td><td><input type="file" name="photo1" /></td> </tr> <input type="submit" /> </form> </body> </html>
  21. I can upload a file to the server and mysql table using php no problem when I display the table using php, no photo, only photo name any thoughts?  here is the display code for this example... <?php include ("link.php"); if($query= mysql_query("SELECT * FROM inventory")) {   $num = mysql_num_rows($query);  }else {   die('There was an error with the query:<br>'.mysql_error()); }  if ($num == '0') { echo "Nothing Exist."; die(); } else { ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <td><font face=Arial>Stock#</font> </td> <td><font face=Arial>Year</font> </td> <td><font face=Arial>Make</font> </td> <td><font face=Arial>Model</font> </td> <td><font face=Arial>Price</font> </td> <td><font face=Arial>Miles</font> </td> <td><font face=Arial>Photo</font> </td> </tr> <? while ($info = mysql_fetch_array($query)) { $stock = $info['stock']; $year = $info['year']; $make = $info['make']; $model = $info['model']; $price = $info['price']; $miles = $info['miles']; $photo1 = $info['photo1']; echo (" <tr> <td> <font face=Arial>$stock</font> </td> <td> <font face=Arial>$year</font> </td> <td> <font face=Arial>$make</font> </td> <td> <font face=Arial>$model</font> </td> <td> <font face=Arial>$price</font> </td> <td> <font face=Arial>$miles</font> </td> <td> <font face=Arial>$photo1</font> </td> </tr> "); } ?> </table> <? } ?>
  22. I set the format of the cell in mysql as blob I uploaded the file using the browse button The file to which the name refers (that was uploaded) is on the server in the same location as the table. The error says there was a problem uploading the file. Any thoughts? Thanks. Any info on uploading files using php and mysql for displaying thumbnailed images is appreciated.  Thanks.
  23. and this will automatically bring up the browse button, right?  thanks. [quote author=mjdamato link=topic=118359.msg483565#msg483565 date=1165955540] You just use an input field with type="file" However, you may want to consider only saving the location & name of the file in the database. [/quote]
  24. Yes, but the several tutorials that I tried had no info on the browse thing...I was hoping for a few other keywords or a specific tutorial that someone knew worked...thanks.
  25. Is there a way to upload files giving the browser the option of using the browse button to select a specific file from the computer?  If so, a tutorial or some brief instructions would be great. I am using a MySQL database and will be inserting the photos (jpeg) into it...for recall and display later (thumbnailed)... I feel I have a grasp on the insert and display portion, just not the browse button feature...thanks.
×
×
  • 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.