Jump to content

phppup

Members
  • Posts

    683
  • Joined

  • Last visited

Everything posted by phppup

  1. I had decided not to let this script bother me, but I couldn't keep away from it. Then I saw your reply. Created a new file with my connection info and WHAM-O, I got a printout of 223 records (not Ordered By) with the printed message stop of each one and all data fields for each. THANK YOU. I notice that you "suppressed email" and I don't want to damage this code. If you can guide me to enable it I can give it a real run. I will compare it with the other messes that I have to see where my mistakes were. Thank you for the lesson.
  2. Even my limited knowledge has allowed me to have confidence in the db and table that I am using. I have a separate script with the same or similar connections to the same table and it successfully echoes all variables in a table. My sense is that there is a disorder in the format of my email or a misplaced } . Either way it appears that the code is allowing a break in the loop (which actually seems NOT to be looping, but rather only running once(at best). Sadly, my original code still comes closest to a successful outcome (since it at least Manfred to send one email. LoL
  3. I copy and pasted the exact code from taquitosensei's post. Then went back to code from my original post.
  4. Substituted //@mail($email_to, $email_subject, $email_message, $headers); print_r($row); and got no results. Although I've not used print_r and am unsure of what to expect I have been monitoring my live email. the results are as follows: My initial 'bad' script sends ONLY one email with a blank message. The repaired script sends no emails but displays my "HELLO" message only. The repaired script with an invalid database name sends no emails but displays my "HELLO" and "Thank you...." messages. Clearly, the items in the loop are not making contact correctly. HELP, please.
  5. Can you show me the correct formatting of the code, please.
  6. Will do. While on the subject, where would I include COUNT and "echo $count" in order to get a final total of number of emails sent?
  7. I will check it again tomorrow and see if there are any abnormalities. Thanks for the help.
  8. That is it. Can it be juggled or repaired to function as desired?
  9. Yes, table x has those columns. As indicated initially in my second paragraph, I have managed to receive 1 email that has complete message content. My problem at that point, is that only one additional email is dispatched, and it has a totally blank message. I am convinced that there is an issue with my loop but I don't see it.
  10. Same problem exists, just a different way of getting there. Your solution gives me field names in email message, but no variable info. Thanks for the effort, but I'm still stuck on this one.
  11. I am having a LOOP problem but cannot seem to resolve it. Maybe some better skilled eyes can re-organize and remedy this. In its presented form, I receive 4 blank emails to 'myrealaddress@xyz.com' which is connecting to my table 'x' which holds 213 records (of which I am querying records with ID>=210. The problem is that the content is missing. At best, I've been able to get the content to display in the first email sent [iD: 210] and then the next email (which would be for ID 211 is blank. No other emails follow, so I assume the loop is being broken. Please assist. echo "HELLLOOOO <br />"; $email_to = "myrealaddress@xyz.com"; $email_subject = " email subject line"; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $telephone = $_POST['telephone']; $query = "SELECT * FROM x WHERE id>='210' "; $result = mysqli_query($link, $query); if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { @mail($email_to, $email_subject, $email_message, $headers); echo "A message was sent to " .$row['first_name']. " >>> ID: " .$row['id']. "<br />" ; } $headers = 'From: '.$row['email']."\r\n". 'Reply-To: '.$row['email']."\r\n" . 'X-Mailer: PHP/' . phpversion(); //mail($email_to, $email_subject, $email_message, $headers); $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "ID: ".clean_string($row['id'])."\n"; $email_message .= "First Name: ".clean_string($row['first_name'])."\n"; $email_message .= "Last Name: ".clean_string($row['last_name'])."\n"; $email_message .= "Email: ".clean_string($row['email'])."\n"; $email_message .= "Telephone: ".clean_string($row['telephone'])."\n\n"; echo "end <br/>"; /* $headers = 'From: '.$row['email']."\r\n". 'Reply-To: '.$row['email']."\r\n" . 'X-Mailer: PHP/' . phpversion(); // @mail($email_to, $email_subject, $email_message, $headers); */ } echo "Thank you for contacting us. We will be in touch with you very soon.<br />";
  12. @ignace (and everyone else) Thru fortitude and determination I got the code working on my own at 2AM. It may not be perfect, but it's doing what I need it to do. I woke this morning and saw your reply. To your credit, much of the problem hinged on your item 2, as I did not realize that the function name DATE was an essential requirement to the code's effectiveness. Thanks for the effort.
  13. Rude? No. I think I was rather polite in explaining and clarifying. Assistance that is helpful is appreciated. But responses that offer no corrections to code I provided and no guidance to resolution are not much help, I'm sure you'd agree. My research lead me to believe there was a single line of code in PHP that would let me add the days. I'm not sure what I got inaccurate, and THAT is why I posted. The second issue is very similar, so insight or correction would be beneficial. Lastly, of there are people with experience like mine, then answers it comments would be helpful.
  14. @Requinix I did say I was going to avoid the drama, but your one line uninformative respondes make it apparent that you thrive and require drama. So here we go: No, START is not a function. The name $start was used in the post to simplify the matter and make it obvious to readers (with the exception of Requinix) of what I was trying to accomplish. Do I need a function? The name of the field (as indicated) is "new date". It is written as one word in all lowercase letters. Got it now??? I don't want to nitt-pick, but 4 questions and a single line that might address 3 is pretty impressive from you. Care to elaborate or torch on the 4th portion?
  15. It all looked so simple on paper... But I'll skip the drama and get right to it: I'm posting $start and want to post $finish as a date that's 3 days afterwards Apparently, this is wrong somewhere: $finish = start('d-m-Y', strtotime($start. ' + 3 days')); echo $finish; On a similar note, I used some script to successfully change mm-dd-yyyy to Y-m-d. echo $newdate; works fine. But POST[$newdate] is not connecting. Any easy answer? And while on the subject, after all this DATE work, I opened Firefox using a form with an HTML input type=date. It displayed mm/dd/yyyy to the user, but intuitively echoed yyyy-mm-dd. Is this a benefit of Firefox or HTML? Is it trusted? Reliable? Will the feature work as default in other browsers?
  16. Got it working. Thanks for all the support.
  17. Note: My hosting service has said the server is fine and the problem is within my code. Does anyone see an issue or have any suggestions?
  18. I'm lost. Please be more specific with detailed instructions, if you would.
  19. I added this immedately after my <? but got nothing.
  20. My form is not posting data to table. I removed all validation to simplification purposes, yet onSubmit only provides a blank page. I have used a script and verified connectivity to the db, and feel as if there is something wrong with my INSERT statement. Here is my code: my_form.php <table width="300" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="POST" action="insert_file.php"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td colspan="3"><strong>Insert Data Into mySQL Database </strong></td> </tr> <tr> <td width="71">Name</td> <td width="6">:</td> <td width="301"><input name="name" type="text" id="name"></td> </tr> <tr> <td>Lastname</td> <td>:</td> <td><input name="lastname" type="text" id="lastname"></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> </td> </tr> </table> insert_file.php <?php $host="localhost"; // Host name $username="provided"; // Mysql username $password="provided"; // Mysql password $db_name="provided"; // Database name $tbl_name="provided"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Get values from form $name=$_POST['name']; $lastname=$_POST['lastname']; $email=$_POST['email']; // Insert data into mysql $sql="INSERT INTO $tbl_name(name, lastname, email)VALUES('$name', '$lastname', '$email')"; $result=mysql_query($sql); // if successfully insert data into database, displays message "Successful". if($result){ echo "Successful"; } else { echo "ERROR"; } // close connection mysql_close(); ?> Do you see something that I've missed??
  21. @Requinix:"Most effective way" to do what, exactly? To work with TIME in general. It seems JS requires manipulations from milliseconds in order to adopt user friendly information. PHP/MySQL appear to be able to accommodate 'real dates', so I avoid an added headache. I'd this a fair assessment? "I shouldn't have to explain why" Perhaps not. But would it hurt if you did? Obviously I'm on the right track because I made the comparison. Èqually obvious is my lack of clarity on the subject because I asked the question. I created my screen name to indicate that I was new and (while eager to grow) still bumping into walls and making (what the more experienced would consider) silly mistakes. The screen name had nothing to do with my affection of canines. "Informative and sensative responses will educate and empower the website capabilities while reducing recycled post volume." Me.
  22. I am planning to use a JQuery datepicker as an easy user interface on a form. This will identify a "start date" that the user will select for his 5 day work shift. The data will go into a table and other calculations will use this start date going forward. What is the most effective way to handle and manipulate this data for this situation? Is there a benefit or best practice? Is it better to format date information using JavaScript on the client side, or with PHP? Should I insert a date as mm-dd-yyyy or yyyy-mm-dd, or something else. Does it even matter? Any helpful hints and opinions to point me in the right direction would be great.
  23. Would you believe that I was unsure of exactly how to make the PDO connection and that the reason I changed to a 'more comfortable' connection was because I could not get the PDO to work? Or do you think that I changed it just to elicit more problems as a means to continue this fascinating dialogue??
  24. OK. Of course, I wouldn't have changed it if I knew where to place the information for the PDO connection. So, let me ask, "where do I put the information so that the PDO-devoted code will connect? And, assuming it does eventually connect, I will be back to my initial question: How do I update the selected record?????
  25. Here's the code straight off the server (sorry, don't know how to encapsulate it). The code is not populating data, and offers no method for 'attaching" the the selected record for UPDATE (which was my initially issue) after dynamically searching the table. <?php //include 'db_inc.php'; $db = mysqli_connect("localhost", "MY_INFO", "MY_INFO", "MY_INFO"); //$db = pdoConnect>>>> REMOVED // AJAX PROCESSING BIT if (isset($_GET['custname']) && trim($_GET['custname']) != '') { $stmt = $db->prepare("SELECT customer_id , fname , lname , phone FROM customer WHERE lname LIKE ? ORDER BY lname, fname, phone"); $stmt->execute( [ $_GET['custname'] . '%' ] ); $opts = ''; foreach ($stmt as $r) { $opts .= "<option value='{$r['customer_id']}'>{$r['fname']} {$r['lname']}, {$r['phone']}</option>\n"; } exit($opts); // return the options as the AJAX response } // report the selected customer if (isset($_POST['customer'])) { echo "You selected customer #{$_POST['customer']}<br><hr>"; } ?> <html> <head> <meta name="generator" content="PhpED 18.0 (Build 18044, 64bit)"> <title>Sample AJAX</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type="text/javascript"> $().ready( function() { $("#custname").keyup( function() { $.get( "sample_ajax.php", { "custname" : $(this).val() }, function(resp) { $("#customer").html(resp); }, "TEXT" ) }) $("#customer").change( function() { $("#fm1").submit(); }) }) </script> </head> <body> <form id='fm1' action="" method='post'> Enter last name<input type="text" name="custname" id="custname" size="20"> <br><br> <select name='customer' id='customer' size=10 > <!-- ajax response text goes here --> </select> <br><br> </form> </body> </html>
×
×
  • 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.