Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. There's a few brands over the years that have won my loyalty through either customer service and / or quality of parts. I don't necessarily rush out and buy a piece of hardware simply because its from XYZ manufacturer, except for certain components. I know enough about computers to piece one together but before I put any system for myself together I do my homework like you did. That's the reason why I have an OCZ PSU instead of Antec that I'd always bought in the past. I should have linked this before, but here is a great site for power users (that you may have come across already) http://forums.extremeoverclocking.com/ Members there constantly post all sorts of builds and it's a great place to see which hardware comes highly recommended. I didn't know you did water-cooling; while big that antec case might be cramped for a water system. I myself had a water-cooled system housed in a custom case built out of clear plastic for a while. It was a beast that inspired awe from all who saw it, but eventually I decided maintaining it wasn't worth the hassle. Fun experiment though!
  2. It looks like you're picking out some pretty hefty parts there. I have a couple thoughts on your other components before I give any input on the memory. I'm not sure if this is the same exact PSU you have listed above, but $130 for a PSU is pretty pricey IMO. I've never used SeaSonic, or heard of them until now, so unless you have a hard-on for the brand I would maybe look into an Antec or an OCZ. Traditionally I've used Antec and I've only ever had one die on me out of the probably 10 I've purchased. I currently use one from OCZ due to good reviews at the time I built my system. I'm not sure if either of these are it exactly, but: $75 500W OCZ - I'd check reviews before thinking about a purchase though http://www.newegg.com/Product/Product.aspx?Item=N82E16817341012 $90 600W OCZ - Looks like some people received defective units and rated it poorly, but an OCZ rep took the time to reply to those reviews and stated that they did have a manufacturing problem and some faulty units slipped through and they will gladly replace them. http://www.newegg.com/Product/Product.aspx?Item=N82E16817341010 As for cases, I always go Antec. Now I couldn't find your exact case on newegg, but I saw the 830 for like $180. Again, if you're set on the brand, more power to you. But here is an Antec case I picked up in Frys, it was love at first site when I saw it. $140 Antec If you check out the pics, the PSU rests on the bottom and overall I think it's internal design is awesome, in addition to looking slick when closed. If you decide to go with it, I'll warn you in advance, the fan at the bottom with a PSU with lots of wires (like OCZ) is a very tight fight. I had a bit of trouble getting mine in, only to discover that I should have put it in from the other side instead (due to wire issues) and then it was a bitch to get out. Apparently the fan can be placed on the opposite side though; and it does have a nice cushioned mounting area for the PSU so its very quiet. The biggest bonus to the case is I can barely hear it. If that coolermaster 831 has as many side fans as the 830, you're gonna get a bit of noise (as well as a dusty case). There also seems to be a $40 rebate for the antec, but I never count on those as givens. http://www.newegg.com/Product/Product.aspx?Item=N82E16811129025 As for the memory, your CPU only supports 1066MHz while your mobo supports 1333/1066. I would say skip the 800Mhz memory, even if you can overclock it. Overclocking results can vary greatly so you shouldn't count on it, plus you mentioned it can overclock to only 900Mhz which is still below what your system can handle. I would say go with 2 x1GB sticks of DDR2 1066 from either ocz, g.skill, or patriot. ocz and g.skill tie for first, patriot comes in second. With a quad-core and 2GB of memory your system should be pretty zippy. Also, you can pick up the 2 x1GB sticks pretty cheaply, in the $100-$150 range; then you pick up some more memory down the road when it comes down in price. Or just buy 4 sticks if you really want to spend the beans. I know more memory is tempting, but I don't know if the extra 2GB is going to make up for bottle-necking the entire system on the FSB, in addition to the hassle of overclocking. Hope that helps some.
  3. Well, if it deletes the old image and then inserts a new one, the record will still be there. To test it, upload a .gif followed by a .jpg and make sure in the DB the record changes from gif to jpg. Or just check that the created field has changed.
  4. Yes, but just to be sure you didn't leave out the other call to mysql_query(), here it is in completeness. $sql = "DELETE FROM `user_images` WHERE `user_id`={$Clean['user_id']}"; $q = mysql_query($sql); if($q === FALSE){ dbg_out('ERROR: ' . mysql_error()); }else{ dbg_out('Database delete successful'); } $sql = " INSERT INTO `user_images` (`user_id`, `ext`, `created`, `modified`) VALUES ( {$Clean['user_id']}, {$Clean['ext']}, NOW(), NOW() ) "; $q = mysql_query($sql); if($q === FALSE){ dbg_out('ERROR: ' . mysql_error()); }else{ dbg_out('Database insert successful'); }
  5. I would think (using MVC) that most of that logic in the top of your view should actually be in the page controller, maybe even as far back as the model. For the majority of logic to be performed, I agree. But what about my example above of the recent news and comments. You surely wouldn't put the code to display recent news in the model as it's not DB related. Moving it into the controller is just about the same as keeping it where it is. Placing those loops into the controller and then just passing the resultant markup into the view just moves the code from one location to another. The code is for display purposes, not business logic, so who is to say it belongs more in the controller than it does in the view? That view is tied to the PagesController, which is the "default" controller in cakePHP. Ideally, I suppose the News and Comments controllers would have methods for retrieving the "recent items" snippets so that they could be called from other controllers, something like: $NewsController->get_recent_news_snippet(); However, that function would merely be opening another view that performs the same formatting. So again, the same code is moved into the same logical place. (Although it does make more sense since it is now the news controller creating the view rather than the pages controller).
  6. You forgot to call mysql_query() after creating the DELETE statement.
  7. The argument goes both ways, but I also fall into the 'avoid the template engines' crowd. PHP is meant to intermingle dynamic data with static data, so why invent another tool to do what the language does natively. When I first learned PHP, the book I was reading suggested creating template files: <i>greeting.html</i> <p> Welcome, {USER_NAME}! </p> <p> Your last login was {LAST_LOGIN}. </p> <p> Lorem ipsum ... </p> To display the page: <i>some_file.php</i> <?php $greeting = file_get_contents('greeting.html'); $greeting = str_replace('{USER_NAME}', $username, $greeting); $greeting = str_replace('{LAST_LOGIN}', $last_login, $greeting); echo $greeting; ?> It worked fine, but it becomes messy in larger sites. Also, if there are a lot of {VARIABLES} to replace in the template, that will be a lot of calls to str_replace which will just keep processing the same text over and over and over; it's horribly inefficient. Another drawback, and I don't know why I didn't organize it better, was I stuck all the template.html files in a single directory; it became impossible to manage. For several months that's how I did it on my own personal site. Then I got the job where I work now and inherited my current project that I still maintain. At the time I inherited it, there were many, many very large files that had PHP and HTML intermingled like you probably have in your own site now. To make it worse, some of them had Javascript and CSS embedded as well. Try sorting through a file one thousand lines long with four different languages in it and on average a <?php or ?> on every other line. IMPOSSIBLE! Because of the horrible entanglement of jumping between PHP and other languages in these files, I was instantly turned off by any method that jumped in and out of PHP-mode frequently. After a while it hit me that the str_replace() method sucked and needed to go. I had heard of template engines and knew the basic idea, but I didn't want to go that route; I see them as only making one pain in the ass a bigger pain in the ass. Then it hit me (and I already said it once in this thread): Now as I semi-mentioned before, other programmers' code that I'd seen that constantly jumped in and out of PHP were difficult to read. I finally came to the conclusion the ability jump in and out of PHP was a good approach and people were right to use it, but also that many were misusing it and creating difficult to maintain code. I finally decided I would start programming this way as well, but with one major rule: As little logic as possible should go into these files; if any logic does need to be in the file, then it should be at the beginning. Basically, there should be as little intermingling of PHP with other languages as possible. I called these files components as they were mainly meant for displaying visual pieces of a web site; now that I've looked into cakePHP and MVC a little, I see that they're more commonly called views, but the concept is the same. Here is sample home page for a cakePHP site that displays the recent news and recent comments, as well as prompting the user to login if they haven't done so already. $recentNews and $recentComments are incoming arrays that will be populated with the entries to display. Since there is a bit of looping and other stuff to be done before the news and comments can be displayed, it would be messy if placed within the HTML. Therefore, to help readability, I place it at the head of the script and store the output in variables. Then in the HTML I use a <?=$var_name?> to print the items. I find that it makes reading the markup much easier. <?php // RECENT NEWS $News = '<p>Nobody has reported any news yet!</p>'; if(!empty($recentNews)){ $News = Array(); foreach($recentNews as $news){ $News[] = $this->renderElement('news/recent', $news); } $News = implode('', $News); } // RECENT COMMENTS $Comments = '<p>Nobody has commented on anything!</p>'; if(!empty($recentComments)){ $Comments = Array(); foreach($recentComments as $comment){ $Comments[] = $this->renderElement('comments/recent', $comment); } $Comments = implode('', $Comments); } ?> <p> Welcome to the Test Site! </p> <?php if(!$session->check('User')){ ?> <p> Please <a href="/users/login">login</a>. </p> <?php } ?> <!-- RECENT NEWS --> <div> <h1>Recent News</h1> <?=$News?> </div> <!-- RECENT COMMENTS --> <div> <h1>Recent Comments</h1> <?=$Comments?> </div>
  8. If I may ask, do you already know C / C++? And is it possible to get an overview of what it is you want the user to do on their local machine? I only ask because if you don't already know the other languages, you will be faced with a steep learning curve. Also, there is the chance you are reinventing the wheel.
  9. Looking at the documentation for move_uploaded_file(), if the file exists it will be overwritten. That means you technically don't have to delete the file off the file system. But you might want to anyways. Because if the user uploads a gif image first and then a jpg, you will have two files for that user (3.gif & 3.jpg). This isn't a problem for display purposes because your `user_images` table should only ever have one entry per user and it should always be the most current one, but your file system will wind up containing images that are never used for anything. It's something to consider if your host doesn't give you lots of disk space. So before you run the INSERT, you should run the following: $sql = "DELETE FROM `user_images` WHERE `user_id`={$Clean['user_id']}"; That will guarantee that your table only has one row per user and that it is the most recent one.
  10. Let's handle the first part of expanding upon this. See if you can add the necessary code to delete a user's avatar if it already exists while they are uploading a new one.
  11. How about this: SELECT `ip`, COUNT( * ) AS `n` FROM `users` WHERE `n`>2 GROUP BY `ip` LIMIT 0 , 30
  12. This line of the code: // Debug print the mime type that was found dbg_out($image_size['mime']); correlates to this line of output: image/bmp This tells us that getimagesize() is supported (and working) on your server. From here it is trivial to validate and rename the file. To validate the file as an image, we will separate the type from the extension. $img_arr = explode('/', $image_size['mime']); if(count($img_arr) != 2){ echo 'Error: Problem with image type'; exit(); } $type = $img_arr[0]; // mime type $ext = $img_arr[1]; // file extension if(strlen($type) == 0 || strlen($ext) == 0){ // Neither of those vars can be zero length echo 'Error: No type or extension found'; exit(); } if($type != 'image'){ // Not an image! echo 'Error: Uploaded file was not an image'; exit(); } Now currently, your code is naming the image after the user's username, which is fine. But what happens if someone (for whatever reason) changes their username? You have to remember to go back and change their image as well. To avoid this, let's name the image after the user's id, which will never change. $id= $_SESSION['user_id']; Next we will change our line of code that sets the destination to use the extension. $dst = realpath(dirname(__FILE__) . '/images') . '/' . $id . '.' . $ext; Now, let's think about how we go about calling this image up later. The images are located in: /home/runningp/public_html/members/images/ They are named with the following format: <user_id>.<extension> So if a user with id 2 uploads a jpg, it will be located in: /home/runningp/public_html/members/images/2.jpg The appropriate img tag is then: <img src="http://www.yourdomain.com/members/images/2.jpg" alt="2's avatar" /> So now let's think of what the givens are. All of the files are stored in the same directory All of the files are named after the user's id The only thing that changes from image to image is the extension; therefore, the only thing we need to save in the database is the extension and which user it is attached to. Here is the create table for the proper database table. CREATE TABLE `user_images` ( `user_id` INTEGER NOT NULL DEFAULT 0, `ext` VARCHAR(4) NOT NULL DEFAULT '', `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' ); Thus, if the user's id is stored in $user_id and the extension is stored in $ext, here is the query to insert: $Clean = Array(); $Clean['user_id'] = "'" . mysql_real_escape_string($user_id) . "'"; $Clean['ext'] = "'" . mysql_real_escape_string($ext) . "'"; $sql = " INSERT INTO `user_images` (`user_id`, `ext`, `created`, `modified`) VALUES ( {$Clean['user_id']}, {$Clean['ext']}, NOW(), NOW() ) "; Putting it all together: <?php session_start(); require_once '../settings.php'; if(!$_POST['uploaded']){ /** * DISPLAY FORM */ ?> <form action="" method="post" enctype="multipart/form-data"> Upload:<br><br> <input type="file" name="image"><br><br> <input type="hidden" name="uploaded" value="1"> <input type="submit" value="Upload"> </form> <?php }else{ /** * PROCESS FORM */ // %% debugging info dbg_out($_SESSION); dbg_out($_FILES); // First line of error checking, make sure upload successful if($_FILES['image']['error'] !== UPLOAD_ERR_OK){ echo 'Error: There was an error with your upload.'; exit(); } // Now we know we have an uploaded file, let's check the type $image_size = getimagesize($_FILES['image']['tmp_name']); if($image_size === FALSE){ echo 'Error: getimagesize() has failed.'; exit(); } // Debug print the mime type that was found dbg_out($image_size['mime']); $img_arr = explode('/', $image_size['mime']); if(count($img_arr) != 2){ echo 'Error: Problem with image type'; exit(); } $type = $img_arr[0]; // mime type $ext = $img_arr[1]; // file extension if(strlen($type) == 0 || strlen($ext) == 0){ // Neither of those vars can be zero length echo 'Error: No type or extension found'; exit(); } if($type != 'image'){ // Not an image! echo 'Error: Uploaded file was not an image'; exit(); } //get users ID $id = $_SESSION['user_id']; //don't continue if an image hasn't been uploaded if(is_uploaded_file($_FILES['image']['tmp_name'])){ // set destination directory $dst = realpath(dirname(__FILE__) . '/images') . '/' . $id . '.' . $ext; dbg_out($dst); // %% if(move_uploaded_file($_FILES['image']['tmp_name'], $dst)){ // Success, file has been moved and renamed // now do whatever else is necessary dbg_out('SUCCESS!'); // %% $Clean = Array(); $Clean['user_id'] = "'" . mysql_real_escape_string($id) . "'"; $Clean['ext'] = "'" . mysql_real_escape_string($ext) . "'"; $sql = " INSERT INTO `user_images` (`user_id`, `ext`, `created`, `modified`) VALUES ( {$Clean['user_id']}, {$Clean['ext']}, NOW(), NOW() ) "; $q = mysql_query($sql); if($q === FALSE){ dbg_out('ERROR: ' . mysql_error()); }else{ dbg_out('Database insert successful'); } } } /* Everything else you had is irrelevant at this point */ } /** * remove this function later and all calls to it */ function dbg_out($msg){ if(is_bool($msg)){ $msg = $msg ? '[TRUE]' : '[FALSE]'; }else if(is_null($msg)){ $msg = '[NULL]'; }else if(is_string($msg) && strlen($msg) == 0){ $msg = '[EMPTY STRING]'; } echo '<pre style="text-align: left;">' . print_r($msg, true) . '</pre>'; } ?> Copy and paste what that code gives you and we can keep going. Now keep in mind so far that we're only handling a user uploading an image. We haven't done anything yet to delete an existing image if it exists. Also, with the arrangement of this current system, each user is limited to a single image. If this is for avatars, then this limitation is fine. If this is for something more complex, like a photo gallery, then there are substantial design changes to be made.
  13. Oops, I made a booboo. SELECT ip, COUNT( id ) FROM users WHERE COUNT( id ) >2 GROUP BY ip LIMIT 0 , 30
  14. I was trying to use the search function to find this post: http://www.phpfreaks.com/forums/index.php/topic,167381.0.html Since I knew calendar was in the title, I tried using just a topic search, limited the search to just the Misc. board, and used the search term 'calendar'. However, no matter what other search parameters I gave (in addition to the search term 'Calendar'), these were the only two topics returned: In need of a planner/manager/calendar script http://www.phpfreaks.com/forums/index.php/topic,146310.0.html Google Calendar Released! http://www.phpfreaks.com/forums/index.php/topic,91115.0.html It wasn't until I unchecked the Search in topic subjects only field that the thread came up. Not sure if anyone else has reported this or if it's a common bug.
  15. I can understand it on a cell phone due to the gimped typing abilities, but if you have a full keyboard there's almost no excuse for it. My big pet peeves are ones like 'ur'. I can't seriously believe anyone would think it takes less effort to consciously misspell a word than it does to hit the extra two or three keys? It also drives me nuts when people don't bother to use the correct versions of: your, you're there, they're, their where, were then, than In college most dorm rooms had small white boards where people could leave messages for each other; it's atrocious how many people in college can't spell. It's even worse to see programmers doing it because it shows a complete lack of thoroughness and attention to detail, which are two very important traits of good programmers. The most common abbreviations are OK by me however, as they are used often and their meaning is clear: lol, rofl, rolfmao (but who types that last one anymore) omg, omgooses (commonly used by me for something utterly ridiculous) brb, ttyl, bbiab, bbiaf, afk I will often use 1337-speak as an alias while playing an online game, but just because it's fun to piss people off.
  16. @arianhojat You can always easily test if something is passed by reference or not. In the function where it is received, just change its value. If the change is reflected in the original object / variable, then it was passed by reference.
  17. SELECT ip, COUNT(id) FROM a_users GROUP BY ip WHERE COUNT(id) > 2 Be warned though that users in public locations (libraries, computer labs, college campuses, etc.) will all come from the same IP until that location receives a new IP address from it's ISP.
  18. @mr_mind You are way off the mark here. Whenever you run a SELECT query you can choose to return a single column, two columns, 10 columns, or every possibly column that would have been returned. The "best practice" is to only return the columns you need. Why? Let's say the average row size is 100 bytes and all you really want is the `id` column, which is an INTEGER. For argument's sake, let's say an INTEGER is only 4 bytes and that your query returns 1000 records. If you select all of the columns (when all you want is the `id`), then MySQL has to return to you a result set that is 1000 (records) * 100 (bytes per record) ~= 97 kilobytes of data. If all you had SELECT'ed was the `id`, MySQL would return only 1000 (records) * 4 (bytes per `id`) ~= 4 kilobytes of data. That extra 93kb from selecting everything is unnecessary overhead. In addition, every single SELECT query that you send through mysql_query() will return a resource identifier. Whether you select 1 field or all of them, printing the return variable of a SELECT query in PHP will always say "Resource id #XYZ." $q = mysql_query('SELECT * FROM `users`'); echo $q . '<br>'; $q = mysql_query('SELECT `id` FROM `users`'); echo $q . '<br>'; Both of those will echo "Resource id #X." In order to obtain your records, you always have to check the result for errors and then perform a loop to run over the returned record set. $q = mysql_query('SELECT * FROM `users`'); print_record_set($q); $q = mysql_query('SELECT `id` FROM `users`'); print_record_set($q); function print_record_set($q){ if(!$q){ echo 'Error: ' . mysql_error(); return; } echo 'PRINTING RESULTS...<br>'; while($row = mysql_fetch_assoc($q)){ echo '<pre style="text-align: left;">' . print_r($row, true) . '</pre>'; } } For the original poster, if you look carefully at what I'm explaining and what you're doing, you'll find where you went wrong.
  19. Based on your code, it appears that you want to store the actual file contents into the database. While you can do this, it makes things a little more complicated. Also, since you already have a copy of the file on your file system, it would be redundant to store it in the database. Let's summarize what we have so far. All of the member images are stored here: /home/runningp/public_html/members/images/ Each image is named after the member's username, thus each member can have only one image. For example, a user named 'bobsmith' would be associated with the image: /home/runningp/public_html/members/images/bobsmith Your website domain maps to the directory: /home/runningp/public_html/ So to display bobsmith's image, you could create this HTML: <img src="http://www.yourdomain.com/members/images/bobsmith" alt="bobsmith's image" /> We have a small problem. Since there is no file extension appended to the file, the browser does not know what type of file it is. Anyone visiting that URL will get a prompt to open or save the file. We also have a related problem. Your upload script is not performing any validation; any file uploaded by the user will be accepted, whether it's a valid image or not. So at this point in time, we can fix two problems at once if we can deterine the file type. There are two ways to do this: 1) Check the value of $_FILES['image']['type']. This field is not trust-worthy however because it is supplied by the web browser. Basically, a user could upload a .php script to delete your entire website but fool the browser into thinking it was a valid image. 2) By using getimagesize() or the fileinfo package. Let's try the getimagesize() approach first. What does this code output (note that I've again commented out your DB stuff, save it for last): <?php session_start(); require_once '../settings.php'; if(!$_POST['uploaded']){ /** * DISPLAY FORM */ ?> <form action="" method="post" enctype="multipart/form-data"> Upload:<br><br> <input type="file" name="image"><br><br> <input type="hidden" name="uploaded" value="1"> <input type="submit" value="Upload"> </form> <?php }else{ /** * PROCESS FORM */ // %% debugging info dbg_out($_SESSION); dbg_out($_FILES); // First line of error checking, make sure upload successful if($_FILES['image']['error'] !== UPLOAD_ERR_OK){ echo 'Error: There was an error with your upload.'; exit(); } // Now we know we have an uploaded file, let's check the type $image_size = getimagesize($_FILES['image']['tmp_name']); if($image_size === FALSE){ echo 'Error: getimagesize() has failed.'; exit(); } // Debug print the mime type that was found dbg_out($image_size['mime']); //get users IP $id= get_username ( $_SESSION['user_id'] ); //don't continue if an image hasn't been uploaded if(is_uploaded_file($_FILES['image']['tmp_name'])){ // set destination directory $dst = realpath(dirname(__FILE__) . '/images') . '/' . $id; dbg_out($dst); // %% if(move_uploaded_file($_FILES['image']['tmp_name'], $dst)){ // Success, file has been moved and renamed // now do whatever else is necessary dbg_out('SUCCESS!'); // %% } } /* You haven't fopen()'ed the file, so $fp1 is unassigned $contents1 = fread($fp1, filesize($filename1)); fclose($fp1); */ /* let's forget about the following until we resolve the is_uploaded_file() and move_uploaded_file() errors //encode the image into text $encoded = chunk_split(base64_encode($contents1)); //insert information into the database mysql_query("INSERT INTO images (img,data)"."VALUES ('NULL', '$encoded')"); //delete the temporary file we made unlink($filename1); */ } /** * remove this function later and all calls to it */ function dbg_out($msg){ if(is_bool($msg)){ $msg = $msg ? '[TRUE]' : '[FALSE]'; }else if(is_null($msg)){ $msg = '[NULL]'; }else if(is_string($msg) && strlen($msg) == 0){ $msg = '[EMPTY STRING]'; } echo '<pre style="text-align: left;">' . print_r($msg, true) . '</pre>'; } ?> Copy and paste what your script outputs and I can continue to help you.
  20. goto does the same thing in all languages that have it; it unconditionally jumps to another point in the code.
  21. Append this: WHERE `task_user`.`created` IS NULL
  22. You should really take the time to try and figure out why this isn't working. The answer is pretty obvious. The first thing my code prints out is your $_SESSION array, which is EMPTY! Since you're trying to set the destination filename based on $_SESSION['user_id'], which doesn't exist, the $id variable is empty as well. Thus the destination you're trying to write to is (wrong): /home/runningp/public_html/members/images/ vs. (correct) /home/runningp/public_html/members/images/filename So why is your $_SESSION variable empty?
  23. I added a debugging function and commented out most of the "fluff." This will upload and move the file into the proper directory. <?php session_start(); require_once '../settings.php'; if(!$_POST['uploaded']){ /** * DISPLAY FORM */ ?> <form action="" method="post" enctype="multipart/form-data"> Upload:<br><br> <input type="file" name="image"><br><br> <input type="hidden" name="uploaded" value="1"> <input type="submit" value="Upload"> </form> <?php }else{ /** * PROCESS FORM */ // %% debugging info dbg_out($_SESSION); dbg_out($_FILES); //from here onwards, we are copying the file to the directory you made earlier, so it can then be moved //into the database. The image is named after the persons IP address until it gets moved into the database //get users IP $id= get_username ( $_SESSION['user_id'] ); //don't continue if an image hasn't been uploaded if(is_uploaded_file($_FILES['image']['tmp_name'])){ // set destination directory $dst = realpath(dirname(__FILE__) . '/images') . '/' . $id; dbg_out($dst); // %% if(move_uploaded_file($_FILES['image']['tmp_name'], $dst)){ // Success, file has been moved and renamed // now do whatever else is necessary dbg_out('SUCCESS!'); // %% } } /* You haven't fopen()'ed the file, so $fp1 is unassigned $contents1 = fread($fp1, filesize($filename1)); fclose($fp1); */ /* let's forget about the following until we resolve the is_uploaded_file() and move_uploaded_file() errors //encode the image into text $encoded = chunk_split(base64_encode($contents1)); //insert information into the database mysql_query("INSERT INTO images (img,data)"."VALUES ('NULL', '$encoded')"); //delete the temporary file we made unlink($filename1); */ } /** * remove this function later and all calls to it */ function dbg_out($msg){ if(is_bool($msg)){ $msg = $msg ? '[TRUE]' : '[FALSE]'; }else if(is_null($msg)){ $msg = '[NULL]'; }else if(is_string($msg) && strlen($msg) == 0){ $msg = '[EMPTY STRING]'; } echo '<pre style="text-align: left;">' . print_r($msg, true) . '</pre>'; } ?> Copy and paste what the above outputs. If it is_uploaded_file() and move_uploaded_file() still produce errors, check the file permissions on the folder you're copying into.
×
×
  • 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.