Jump to content

phppup

Members
  • Posts

    683
  • Joined

  • Last visited

Everything posted by phppup

  1. Last line should read: make sure your $ret is positoned correctly to avoid sending multiple emails with the same content.
  2. It sounds like you've got something working. (which is a plus) and now just need to tweak it to for your specifications. There are many more qualified coders here than me, but here's my opinion. If I understand your dilemma, you are receiving one email per student but would prefer receive a single email with the information of all the students. I would suggest adding an IF statement that surrounds the entirety of your applicable code. You can either ADD another column (maybe MEMBER) and sort through with the IF statement. Or, analyze an existing column that is applicant (maybe attendanc_date). So, if attendence_date is March 1 [2020-03-01] THEN put the six lines of $msg into the body of the email, otherwise, skip the row. You will want to add an additional \n at the end of your $msg to make the email body more presentable and break up the information. Also, in this instance, make sure your$ret is pristine correctly to avoid sending multiple emails with the same content. Good luck.
  3. I created scripting to upload multiple images simultaneously. The files sizes allowed for upload are 2 MB (or larger) and are then resized to approx 300kb each. In testing, I have discovered that the uploading terminated after 20 images. Is there a variable that needs to be re-defined in order to easily allow uploads of several hundred images? PS: I've seen several conflicting examples for defining max_file_size. What is the correct math to define this parameter?
  4. I'm trying to create a series of web pages that will lead to a FINAL SALE page. At that point, I require TWO things to happen. First, the customer must pay the displayed total. Second, some kind of automated receipt needs to be generated so that a script can allow the customer to progress further. An applicable example would be a customer navigating through web pages of paintings by different artists and then choosing to see Alfred's latest unreleased paintings for a $2 fee. After paying the $2, the next web page would validate receipt of the payment, and now allow the customer to access Alfred's gallery. Is there a template for this sort of thing? Obviously, an online payment would require a credit card. Any recommendations for service providers would be appreciated. I have contacted Pay Pal, but they seem trained to encourage Ebay type sales and insist that the email I receive as confirmation would be sufficient. However, that would require me to check my email and manually grant access to galleries without ever sleeping. LOL. I'm sure there is a more viable solution, but need some advice and guidance from those that have already traversed this obstacle.
  5. Got it working. Cleared up my error messages. Even re-wrote it in Procedural style for my clarity. Thank you all for your input. Thank you, <strong> sensei </strong>
  6. select max(id) as maxid resulted in: ERROR: Could not able to execute select max(id) as maxid. Unknown column 'id' in 'field list' $sql ="select max(id) FROM persons as maxid"; still provided NO result
  7. $sql = "SELECT MAX(id) FROM persons" ; if($result = mysqli_query($conn, $sql)){ if(mysqli_num_rows($result) > 0){ echo "<br /><br />ROW ".$row['id']."<br /><br />"; } } gives me: ROW and an ERROR message of "Notice: Undefined index: id"
  8. Field Type Null Key Default Extra id int(11) NO PRI NULL auto_increment first_name varchar(30) NO NULL last_name varchar(24) NO NULL email varchar(70) NO UNI NULL sum int(11) NO NULL Persons is a simple table made up of some simple columns: id, first_name, last_name, email, sum.
  9. Yes, MCONTE, both of those seem to work, but apparently mysqli_insert_id($link); works ONLY during an INSERT and not as a method to SELECT (independent of an INSERT in the same script). Barand, I have a simple table being displayed row by row that is giving me results from other script efforts. Didn't want to waste space by posting it. echo "</tr>"; while($row = mysqli_fetch_array($result)){ echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['first_name'] . "</td>"; echo "<td>" . $row['last_name'] . "</td>"; echo "<td>" . $row['email'] . "</td>";
  10. I've tried the following alterations $sql = "SELECT MAX(id) FROM persons" ; $sql = "SELECT * FROM persons WHERE 'id=MAX(id)'"; $sql = "SELECT * FROM persons WHERE 'MAX(id)>0'"; and variations of them
  11. OK, used ginerjm's code and got results, so at least I have eliminated some basic concerns. Still curious why MAX(id) is not working for me when I try to SELECT results.
  12. My first post indicates that I am having TROUBLE with MAX(id)
  13. YES, I realized my error and deleted my post. Obviously turning error reporting OFF will provide NO assistance. Dumb mistake. After a day away, I am reviewing my efforts. I see that I need to loop through all the records to accumulate data. At this point I guess my question (due to unexpected non-results) is how can I simply SELECT the MAX(id) row successfully? Apparently, mysqli_insert_id works ONLY during an INSERT, but how can I obtain that row's data independently with SELECT? Can I reference the second-to-last with that information minus 1?
  14. Still not getting the connection in PHP (although the SQL seems to work in the db) $sql = "SELECT first_name , sum , FORMAT(@balance := @balance + sum, 2) as balance FROM persons JOIN (SELECT @balance:=0) as init WHERE id = 25"; result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { echo "TEST" . $row['id'] ; } }
  15. Shouldn't this give me a result? test = "SELECT first_name , sum , FORMAT(@balance := @balance + sum, 2) as balance FROM persons JOIN (SELECT @balance:=0) as init WHERE id = 25"; echo $test;
  16. I understand. However, what if I wanted to know the balance after Carol made her deposit? Hypothetically, isn't it simpler to print the calculated data result for a given period than to run the computation for each transaction at that point? I appreciate the help and shared knowledge. Thanks.
  17. Currently very simple to get a handle on the approach, id, name, add, sum I've INSERTED 3 or 4 rows with random data. Now I want to access the LAST value for SUM. Afterward, I expected to INSERT the ADD value to the LAST (sum-1) to create a running balance. [There will be no subtractions, although I assume a negative number would thereby reduce the SUM]
  18. I am trying to generate data similar to a running balance for a checkbook. My approach (correct me if there is a better method) is to get the balance from the previous record ID and then add/subtract the new value and create a new total balance. However, I am not havig succes with MAX(id) or last_insert_id -- is one preferable over the other?? if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ $sql = "SELECT MAX(id) FROM persons"; echo "<br /<br />"; echo $sql; Please assist.
  19. Yes, yes, the code. But first, I'd like to try to resolve this with some education. (especial since I've managed to get the basics of the code working). And I'm wondering if I may be creating my web of complications unnecessarily. So here's a question (that may unravel some mystery and resolve my issues): are there a set of BEST PRACTICES for handling images? After I have uploaded several images, I want to resize and watermark them. At first, my thought process was to create separate functions and call them accordingly upload(); resize (); watermark (); Then I wondered whether I was creating unnecessary redundancy and server load. Am I grabbing the image and writing it to my /images_folder and then grabbing it again to resize and overwrite it, then re-grabbing it and watermarking it and re-overwriting it again? Is that creating workload? Is it better to nest the watermarking function within the resizing for a more streamlined flow? Or does that create impracticalities of it's own?
  20. It's always these seemingly simple tasks that become challenges. I got a good handle on how to watermark some photos (thanks to respondents to my previous post) and developed a script that calls a function that uses imagettftext() Essentially, I can upload multiple images and watermark them before they reach their destination folder. Good stuff. Now, I got this crazy idea of watermarking them with a sequence number, so that if I grab 12 images, each will be labeled with it's sequence number (rather than a standard text watermark). I placed $count++ in my script, and then used $count as my $watermark both inside imagettftext and as a variable. It didn't work. The closest I got was after placing $count++ inside a watermark function, but. of course, that merely labeled each photo with a "1" (bc each call of the function was a new iteration. Can someone please offer some direction here. Thanks.
  21. I want to watermark a simple TEXT line on some images (ie: "SAMPLE") I have successfully created a working code and using imagettftext and the PHP manual, I have summized that the coordinates 0,0 will essentially place the beginning of the text at the top left corner of my image. This would remain the same regardless of the image size or shape. Are there coordinates that will consistently designate the lower-right corner? Do the coordinates change for horizontals and verticals; large files and small?
  22. How can I reverse sort from Z to A? Or by last modified?
  23. This has got to be the UGLIEST CODE that you've ever seen, but I'm sure you'll take some conciliatory victory laps in knowing that IT WORKS. I went from the original echo scanDirectoryImages("uploaded"); $directoryList = opendir($directory); while($file = readdir($directoryList)) { if ($file != '.' && $file != '..') { $path = $directory . '/' . $file; to echo scanDirectoryImages("uploads"); // $directoryList = opendir($directory); // no longer necessary to create the handle $directory = "uploads"; //establishes the folder to be located and scanned // while($file = readdir($directoryList)) { // REMOVED as the wrong approach for glob() foreach (glob("$directory/*") as $file) { //OR foreach (glob($directory."/*") as $file) { //BOTH WORK with either QUOTE MARK scheme (is one more correct?) //foreach (glob("$d/*") as $file) { //part of the Learning Process to determine if a variable needed different handling than a hardcoded routing /***** SAMPLE to work with and TEST *****/ //foreach (glob("uploads/*") as $filename) { //echo "$filename size " . filesize($filename) . "<br />"; echo "$file size " . filesize($file) . "<br />"; //PROVED SUCCESS using variable name $file to avoid conflicting names from TESTing to established script if ($file != '.' && $file != '..') { //no longer necessary, but will not interfere. Let's get functional before pretty // $path = $directory . '/' . $file; $path = $file; //the NEW variable $file INCLUDES $directory AND slash; this was easiest solution. //And it worked. //not sure if it better seperated since listing file NAMES would be neater than the ENTIRE PATH //Best way to break it up???? I hope this validates the sincerity that you doubted earlier. Perhaps you can offer a few (or bunches) of tips for better functionality and clean up. PS: I'm still considering a different/more simplistic script and wonder in recursion is beneficial or just stylish. Thanks for the guidance.
×
×
  • 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.