Jump to content

Pacopag

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by Pacopag

  1. Good suggestion, but didn't work. It's never been clear to me when to use mysql_real_escape_string and when not to. I always figured I should apply whenever I'm writing a string to mysql tables.
  2. But I'm writing $phpgetbrowser to the same table in exactly the same way elsewhere in the script. It's the same 3 lines of code that works in one place but not another. Thanks for your reply.
  3. Hi. I'm having a problem that is making me hostile. All I'm trying to do is to write the result of $phpgetbrowser = mysql_real_escape_string(print_r(get_browser(null, true), true)); to a mysql table. The data type in the table I'm using is varchar(800). So I do $sql = "insert into browsers values ('".$phpgetbrowser."')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } What's making me crazy is that I copied and pasted this latter code from elsewhere in the script, where it works fine. I'm sure that the mysql connection has already been made, and that $phpgetbrowser is initialized. I get the following error Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Array\n(\n [browser_name_regex] => ^mozilla/5\\.0 (.*linux x86_64.*) applewe' at line 1 Any help would make me a much happier man. Thanks.
  4. CPE0015e96c1a35-CM001ac35df5b0.cpe.net.cable.rogers.com
  5. When I do echo(gethostbyaddr($_SERVER['REMOTE_ADDR'])); I get some kind of key followed by what looks like a domain related to my isp. What exactly is this, and how uniquely does this identify the client? Can this be easily changed by the client user? Also, how would I use session ids to do what I'm trying to do?
  6. wouldn session ids get destroyed by system restart, or by using a different browser?
  7. Wouldn't mac address be a good way to identify unique visitors? Can it be done client side, say javascript, and ajaxed to server?
  8. What is the difference between $_SERVER['REMOTE_HOST'] and gethostbyaddr($_SERVER['REMOTE_ADDR']); ???
  9. The voters are not necessarily registered users. I suppose I could create a session variable for each visitor, but wouldn't that get destroyed if they just reset their computer? I was thinking maybe writing their ip and machine name to a db to use as a unique id, but I'm not sure how to get the machine name. I think that gethostbyaddr() might work, but I read that it only works on Windows. Is there any other info about the visitor that I could retrieve that would identify them as unique?
  10. Hi. I'm running a photo contest where viewers vote on the photos. Right now I'm limiting the number of votes to 2 per ip address, per day. But I'm worried that some people will know how to change their ip address and vote many more than twice per day. Does anyone know of a good way to do something like this? I want each unique visitor to be able to vote on each picture only twice per day. Thanks,
  11. Yeah. I'm getting that feeling. I think that w3schools may be a good starting point, but you really gotta dig much deeper than what they give you to do things "right". Thanks for the advice.
  12. Thank you extremely much for the detail of your example. I really appreciate it. And you taught me the value of rigorous error checking. It turns out my problem is that the files are just too big. I learned this from the output of $_FILES["somefile"]["error"], which gave error code of 1. Man I feel like a dolt now. Thanks again for your help.
  13. Hi. I have a site where users can upload image files. I currently accept only .jpg images. The problem is that some .jpg files just DON'T upload, and my users are becoming discouraged. However, if I take a .jpg file that refuses to be uploaded, and I just re-save it using Paint (i.e. open with Paint and just "Save As" a jpeg), then the re-saved file uploads no problem. Here's how I'm doing the upload. The html form part <form enctype="multipart/form-data" action="uploadpicture.php" target="some_target" name="someForm" id="someForm" method="post"> <label for="somefile">Filename:</label><input type="file" name="somefile" id="somefile" onchange="document.someForm.submit();" /> </form> The php part (i.e. in uploadpicture.php) include('SimpleImage.php'); if (($_FILES["somefile"]["type"] == "image/jpeg") && ($_FILES["somefile"]["size"] < 50000000)) { if ($_FILES["somefile"]["error"] > 0) { echo "Return Code: " . $_FILES["somefile"]["error"] . "<br />"; } else { $image = new SimpleImage(); $largeimage = new SimpleImage(); $image->load($_FILES["somefile"]["tmp_name"]); $largeimage->load($_FILES["somefile"]["tmp_name"]); $w = $image->getWidth(); $h = $image->getHeight(); if ($w > $h) { $aspect = 'w'; $largeimage->resizeToWidth(798); $image->resizeToWidth(225); } else { $aspect = 'h'; $largeimage->resizeToHeight(798); $image->resizeToHeight(225); } $image->save('newuploads/small.jpg',IMAGETYPE_JPEG,75,null); $largeimage->save('newuploads/large.jpg',IMAGETYPE_JPEG,75,null); } } The SimpleImage.php file can be found at http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/ Can someone identify why I might be having this problem? Or maybe give me another way to upload and resize images that works well.?
  14. Very sorry. Nevermind, I found the problem. I had the url mixed up with a page on my localhost.
  15. I don't know how else to explain this. I have two php pages in the same domain, same folder, with exact same line to connect to mysql, and one works, and the other doesn't. I have no clue. This is the line $con = mysql_connect("localhost", "myusername", "mypassword");
  16. Suppose I have two versions of the same website; one American and one Canadian. This site has members with profiles etc. The way my site is written, I think that if someone were to login to their account on, say, the American site, then a session variable would indicate that a user is logged in on the client machine. Now if they visit the "profile" page, for example, or some other members-only page ON THE CANADIAN SITE, and start manipulating data etc., then this would affect the databases for the Canadian site, and everything would get screwed up (actually, I think mysql would just start spitting out errors, but that's not good either). Does anyone have some simple way to deal this this kind of thing? I don't really know exactly how session variables work. Say I have two domains, somepage.com and somepage.ca on the same server/DNS. If a page on somepage.com sets a session variable called $_SESSION['somevar'], and a page on somepage.ca also sets a variable called $_SESSION['somevar'], are the two variables somehow distinct because they are on different domains? Like, if somepage.com sets the variable, then somepage.ca check if the variable is set, what will happen? What if I wanted to set up the two pages in subfolders, like somepage.com/us and somepage.com/ca, how would I deal with distinguish session variables for the two sites? Is one approach (i.e. distinct domains vs subfolders) better than the other? Thanks,
  17. Hi. I tried what you said. When I click the link, it displays the image I want to see. Does this verify that it's not a permissions issue?
  18. Hi. I'm using SimpleImage.php to do some basic image manipulation. The code is here http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php, but I don't think all the details are important. Basically, I'm trying to read and image and save it with a different name. I'm really new with this stuff, so it's probably something simple. Anyway, here is the code throwing the error, $image_info = getimagesize($filename); where $filename is a string containing the path to the image I want to load, e.g. $filename="images/picture.jpg"; It's throwing a "Read Error!" I know that the path is correct. In fact I first check if the file is there using is_file($filename); and it returns true. I'm guessing that maybe php does not have "permission" to read this file. The permissions for the file are -rw-r--r-- 1 www-data www-data 80211 2011-04-20 16:19 picture.jpg Looks like everyone has "read" permission, so I don't see what the problem is. Also, the permissions of the folder and all parent folders are 777. Not sure what the problem is. I might be way off by guessing that it is a permissions problem. Any help would be great. Thanks. Also, I was wondering if there is a way for this forum to email me whenever there is a reply to my posts. I can't seem to find the option anywhere.
  19. Hi. I have a page that allows users to upload some files, using <input type="file">... What I would like is to be able to upload the file "onchange" of this input field using ajax so that (1) users can upload their second file while their first one is uploading, and (2) so that they can see their file on the page as soon as it's done uploading. But I can't seem to find a way to populate the $_FIlLES array without actually submitting the form. I've seen some stuff online where people use iframes to do this kind of thing, but I was hoping there was another way to do it. Any help would be great.
  20. After a whole day of try..fail..try...fail...and so on, I gave up on postfix. I found a working solution that uses PEAR at http://stackoverflow.com/questions/712392/send-email-using-gmail-smtp-server-from-php-page Installed PEAR and tried the code at the link above and it worked. Here is the working code (had to fix one small error pointed out in a later post) <?php require_once "Mail.php"; $from = "<from@gmail.com>"; $to = "<to@yahoo.com>"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $host = "ssl://smtp.gmail.com"; $port = "465"; $username = "myaccount@gmail.com"; $password = "password"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } ?> <!-- end of php tag-->
  21. So I installed dovecot-postfix, but mail() is still not working. I tried changing smtp_port = 465 to smtp_port = 25. And also tried commenting this line out completely from the php.ini file. Also, from what I read, postfix doesn't use sendmail, so maybe I need to change the line sendmail_path = /usr/sbin/sendmail -t in php.ini to something else? Can anyone tell me how to configure php to jive with postfix, or maybe a useful link? Google returns lots of stuff, but the config instructions are hundreds of lines long. I'm hoping that in reality it's just change a couple lines here or there in a few files. Also, I tried putting everything the way it was when it was working at the office. Then I bypassed the router (plugged straight into the modem), and it still didn't work. So my original theory about the port being blocked is squashed. I guess I gotta get postfix working.
  22. Sounds good. Should I install just postfix? or dovecot-postfix? I just need something simple for testing purposes.
×
×
  • 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.