Jump to content

robertlob

Members
  • Posts

    11
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

robertlob's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I found a working solution: Removed this line from my code... $row = $result->fetch(PDO::FETCH_ASSOC); and it seems to solve the problem. The is a similar Q in the FAQ section, although it regards mySQL instead of SQLite. "The function returns the next row in the result set and advances the internal pointer. So before your loop runs, you're already pointing at the second row in the result set." Removing that line allows it to start at the first row." -Robert
  2. The following snippit should retrieve 10 images stored in an SQLite database table. But for some reason that mystifies me, it only retrieves 9. (Or one less than the number of images that are actually stored on the table): ___________ # retrieve photos for this property $query = "SELECT * FROM binary_data where propID = $prop_id"; $result = $db->query($query); $row = $result->fetch(PDO::FETCH_ASSOC); # save each image data to file foreach($result as $row) { $filename = $row['filename']; $image = $row['bin_data']; file_put_contents($filename, $image); } ?> _____________ It saves the ones it gets to the temporary files as it should, and they appear on the webpage as they should. But one is always missing. Any suggestions/corrections appreciated. -Robert
  3. Gentlemen- Thank you. Fastsol for reminding me I forgot the {}; and Psycho for straightening us both out. It's working fine now. I appreciate your help. -Robert
  4. I am trying to convert and old website from mysql database to sqlite. One of the chores it must do is collect information from the database and put it in a list/menu select box on a page so the user can choose which item to pursue. In the following (incomplete) snippit, I am doing something incorrectly because the sql query does get the proper information (I can put it in a table on the page just fine). But I'm having trouble getting the information into the select options on a list/menu. It appears to be putting them all, one after the other in the first option spot. The last one seems to be the only one of 6 or 7 that shows up. It's been 10 or 12 years since I've messed with php, so I think I'm way behind... any help would be appreciated. --------------------------- <form action="sqlPropDisplay.php" method="post" id="Residential"> <select name="ResidentialListMenu" size="7" id="ResidentialListMenu"> <?php try { //open the database $db = new PDO('sqlite:bilgerdb'); $result = $db->query('SELECT PropID, PropLocation FROM property WHERE PropCategory = "Residential" ORDER BY PropListingDate'); } catch (PDOException $e) { print 'Exception: ' .$e->getMessage(); } foreach($result as $row) $rec = $row['PropID']; $loc = $row['PropLocation']; ?> <option value=<?php echo $rec ;?> selected><?php echo $loc ;?></option> </select> //submit button code omitted. I think I can handle that when I get to it ---------------------------- Thank you, Robert
  5. mj- Thank you so much. Lots of reading and better ideas than I was coming up with. Appreciate the assistance. I already have one of them in the works.
  6. Thanks, guys - The webpage is a listing of officers and directors of a small fraternal organization. Each listed person would have a link that when clicked would call an email form from the viewer's familiar email client in order to contact that person. Very simple, except for the potential of spam harvesters. Viewers could email membership inquires, etc., and the officers/directors would have a simple place to email each other back and forth using their regular email client. I'm sure they would still receive some crackpot messages, but I'm trying to limit their exposure to automated email address harvesters. Obfuscation like "robertlob at huges dot net" or "spamtrap.robertlob@huges.net" where they are supposed to modify the address on the mail form by removing the "spamtrap." just complicate things. Most of these folks are elderly and not computer gurus. Using a php form would work, but it doesn't use their familiar email client, nor leave a copy of the "sent" message. Captcha, I'm afraid, would mess up their mind. I was hoping to use a php script to do the lifting while keeping the actual email address invisible in the source code view. My attempt (below) loads when the page loads so the address does show in the source code view all the time, just like the regular "mailto:" link. Which defeats the purpose. <?php $mailRobert = 'mailto:robertlob@hughes.net'; $href_anchor = "a href= " . $mailRobert . " /a"; $mailLine = "You can email me <" . $href_anchor . "> Here"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <?php echo $mailLine; ?> </body> </html> Could I incorporate some Javascript to call similar php code only "on click", and auto delete it once the client email form appeared on screen? Would that at least limit source code exposure to a few seconds while the email client form was called? Opinions, suggestions all appreciated. [attachment deleted by admin]
  7. Is there a way of using php to keep spam-bots from harvesting email addresses from a web page by calling a php function that would do the same thing as a "mailto:" link in html? I'm thinking php doesn't show up in source file code on a browser, so maybe it would work. I just need a link on the webpage that says "Email Me" and calls a php function that would open a mail form from the resident email client on the user's computer. It would of course, show the "To" address to the user, (but hopefully not to any non-human bots) who would fill out the rest of the email and send it on its way just like a normal "mailto:" link does. Any suggestions on how to go about this, or am I all wet??
  8. Thank you for the link. I am wondering if this solution requires a separate form from other form elements that can be handled by AJAX, or if it can be worked into the single form? I have not had time yet to study on it, so maybe that answer will be obvious once I look closer at the work around. Appreciate your help, Robert
  9. Ok - It does not show a "required field" error, when I add that error code. But it does show a $img_error as 1 on the ..._xml.php results, which means that the file exceeds the max_file_size allowed by php.ini. On the .php handler, it shows a $img_error of 0 or no error for the same file. The file is only 44KB The max_file_upload_size in php.ini is 4M (increased from default 2M) What gives? anybody know?
  10. Among other inputs, my HTML form contains an input file selector for an image (jpeg). In non-AJAX, the php file opens the $_FILES['photo'] and retrieves the tmp_name, name, size, type, and error values and posts the image data to a mysql database table correctly. In the AJAX version, the ..._xml.php file appears to work, but the image values are all null or empty. using: if ($_FILES['photo']) { $img = $_FILES['photo']['tmp_name]; $img_name = $_FILES['photo']['name']; $img_size = $_FILES['photo']['size']; $img_type = $_FILES['photo']['type']; $img_error = $_FILES['photo']['error']; $binary_data = addslashes(fread(fopen($img, "rb"), filesize($img))); $sql = "INSERT INTO binary_data VALUES ('','$binary_data','$img_name','$img_size','$img_type','$rec')"; $r = mysql_query($sql, $dbc); if (mysql_affected_rows($dbc) == 1) { //do something } ...where '' is the auto incremented db record, and $rec is defined elsewhere as a key to a record in a related table. The only data that makes it to the database is the auto incremented record number and the $rec value. None of the image data appears. No error shows, and AJAX reports the image added correctly in the <result> area of the form. Do I need to use a different syntax in the ...xml.php file? When tested the non-AJAX way, the data is properly added to the db using this code. I haven't been able to find any examples addressing using $_FILES() for images in a ..._xml.php file, so any assistance would be appreciated. Thank you, Robert
  11. I'm also having a php problem responding to Pay Pal IPN notifications. I have php script that gets the IPN information and I can put it on/in the Thank You for Buying Something page just fine. In my case, I need for that page to also send the buyer some information (registration key, etc) after I have processed the returned IPN variables. I have a php script that will send the required email to the customer from my server. That works fine by itself. But when I try to integrate it with the first script, it won't send the emails and gives me an empty array() error. Does anyone know how to get such a setup to work properly? I see websites that do it all the time, but I'm at a loss for how, and not all that experience with php to beign with. Any pointers would be great. Thanks Robert
×
×
  • 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.