Jump to content

darga333

Members
  • Posts

    53
  • Joined

  • Last visited

    Never

Everything posted by darga333

  1. Hey I am sorry I wasnt more specific. My appologies for that. These certificates are generated with php, they are certificates for free prizes. 1 certificate might be a free pizza, one might be a free oil change, etc. so we only want them printing the certificate once. currently we have a print button for them. when they click it, it allows them to select how many copies they want. This is not good because they can print the certificate multiple times. Any suggestions on how to make sure that the person that wins the certificate can only print it once? [!--quoteo(post=370749:date=May 2 2006, 07:25 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 2 2006, 07:25 PM) [snapback]370749[/snapback][/div][div class=\'quotemain\'][!--quotec--] well... depending on what these certificates are used for... for instance, do you mean it's a coupon for like 10% off a product or something? you could always track keep info in the db along with the user's other information that says whether they've used one before or not. you could also track their IP address and make your script not display the certificate at all to the same IP address. But people can get around this if they really wanted to, if they go through a proxy server. I mean, I guess it just depends on what these certificates are used for. If you give some more details we might be able to find some other means for people to not necessarily print them, but USE them. [/quote]
  2. [!--quoteo(post=370701:date=May 2 2006, 04:53 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 2 2006, 04:53 PM) [snapback]370701[/snapback][/div][div class=\'quotemain\'][!--quotec--] nope. that's a client side thing. it's built into the OS. At least, you can't do that through php, anyways. You might possibly be able to do it with javascript or an applet or possibly some vbscript but I don't know. But not with php. [/quote] what would you recommend typing into google for a solution? is there any technical term that I should be using? see we have these certificates that we only want the user to print one of them. and then not the page will no longer be available to keep them from printing multiples
  3. hi i want to print a page only once is there a way to print directly through php without using that print dialog box that pops up?? because i only want the user to be able to print 1 page. not multiple pages
  4. well from what i understand, you can not file_get_contents is to get the contents of a file not a directory so you need to get the contents of your file that u want stuff to show up in <?php $blank = "location for blank.gif"; $bar = "location for bar.gif"; $message = file_get_contents("some_file"); //then you want to check that entire file called some_file, and replace the variables with what you want $message = str_replace("%BLANK%",$blank,$message); $message = str_replace("%BAR%",$bar,$message); ?> remember, you would need to go through your some_file and replace the entire location of those variables with %BLANK% or %BAR% but honestly i have no idea what you are actually tryign to do here.. that just worked for me because i was using some_file as a email_template.. then i had to strip the shit and replace it just so i can get my php variables inside that file. but seriously, come back to me in a good 3 months, i will probably know what i am talking about then i am very sorry i couldnt help more
  5. hey i didnt know that function existed.. strtotime(); if i would have known that i would have saved a lot of lines messy code! thanks! hopefully both of our posts help!
  6. forgive me if i am wrong but i would think you would just need to modify this line header("Content-Type: image/jpeg"); i dont know the syntax but i would make it something like this header("Content-Type: image/jpeg/JPEG/GIF/gif/PNG/png"); does that work??
  7. I dont understand why you couldnt just use file_get_contents(file_name); and use php to replace the variables so you get your images and everything do you store your image paths in the database? if so it should be easy do a query to get all the variables you need including the image locations in the page that you want all of the images to show, etc. just put place holders in their spot and use str_replace to swap the placeholders with the stuff you want to show ex. $message = file_get_contents("mailer_template.php"); $message = str_replace("%REP%",$rep,$message); $message = str_replace("%USERNAME%",$username,$message); $message = str_replace("%PASS%",$pass,$message); $message = str_replace("%BUSINESS_NAME%",$business_name,$message); $message = str_replace("%DISCOUNT_MESSAGE%",$discount_message,$message); i'm a newbie so i may be completely wrong, but i just learned about str_replace today and it worked like a charm for me! either way let me know!
  8. Hey Andy! What in the world are you doing to process 5 million lines daily! I dont know if anyone has any experience with that. I am a beginner but what I would do if I were you, is store the last successfull line it reads into the database.. then have it refresh the page so it continually does your entire file until its finished.. had the same problem with something a good 1000 times smaller than what you are working on lol ok bare with me, this might look confusing but it really isnt. // this section should be at the very top of your script $number_per_load = 100; if (!isset($_GET['start'])) { $_GET['start'] = 0; } if (!isset($_GET['redirect_number'])) { $_GET['redirect_number'] = 0; } //ENDING TOP SECTION Then in the $sql statement that is ganna query the database for this million lines of code you are going to need to add LIMIT ".$_GET['start'].", $number_per_load at the very end of that SQL statement. $number_per_load should be the last thing in your $sql statement. then you are going to need to set $i = 0; one line above your while loop... then run your while loop. inside your while loop, after all the code that you use to parse, you need to include this next bit of code you are ganna have to get the line of data you were last successfull with and store it in a temporary table in your database like as follows $sql_3 = " INSERT INTO `tmp_mail_count` VALUES ('$user_id') "; $result_3 = mysql_query($sql_3); $i++; if ($i == $number_per_load) { $start += $number_per_load; $_GET['redirect_number']++; if ($_GET['redirect_number'] > 10) { header("Location: your_script_name_here.php?start=$start"); } else { header("Location: $_SERVER[PHP_SELF]?start=$start&redirect_number=$_GET[redirect_number]"); } } Did you follow all of that? What this is basically going to do is run through your entire SQL query without the page stalling because it is going to continue to refersh every time it hits the limit.. now you can increase the $number_per_load variable to higher than 100 ofcourse.. i used that because of the particular query i was using. Anyways, let me know how it works for you! & Please do tell me how much money you are making! 5 million lines of code a day should be a good $50K a month! [!--quoteo(post=369011:date=Apr 26 2006, 05:32 PM:name=andyj)--][div class=\'quotetop\']QUOTE(andyj @ Apr 26 2006, 05:32 PM) [snapback]369011[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi, I need to load and parse a very large XML file (over 5 million lines) daily, and then dump its contents into a database. I increased the max_execution_timeout to 5 minutes. However, the script seems to stop after 30 seconds or so. No error is printed, and it stops in a different place each time. I'm printing the execution time in my script, using ini_get, to make sure it's 300, and it is. Any other reasons this may happen, or tips for reading such a huge file? I tried using 2 scripts and passing the last byte read between them using fseek(), but b/c i'm passing a url to fopen, it looks like I'm out of luck there. Any help much much appreciated! Thx. [/quote]
  9. I finally have created a template that looks halfway decent, I was wondering if anyone knows of a good newsletter system. Something that you can create emails much in advance, and then ofcourse you can modify them later.. and it is somewhat easy to modify to personalize. For instance, I am going to have an email go out on Christmas, Thanksgiving, New Years, and several more ocasions. The ones for the holidays can be pretty much created in advance. Anyone know of a good system to use? or is the best way just creating my own system. Create all my emails by scratch, store the filenames in the database, and then write a file to check the date, if the date is this, then send this email.. and so on for every single ocasion. I am completely lost at tryping to fathom creating a newsletter system. How exactly would I go about creating my own newsletter system?
  10. Hey thank you so much! I had no idea that you could even do that! It works now! [!--quoteo(post=369073:date=Apr 26 2006, 07:56 PM:name=KrisNz)--][div class=\'quotetop\']QUOTE(KrisNz @ Apr 26 2006, 07:56 PM) [snapback]369073[/snapback][/div][div class=\'quotemain\'][!--quotec--] If you want to keep your code separate from your template then you shouldn't have php in it. Use placeholders in your template for the pieces of the email that are going to change. e.g [code] #template.html Dear %NAME%, thanks for registering with %SITENAME% #code $personsName = "Bob"; $siteName = "foo.bar"; $body = file_get_contents("template.html"); $body = str_replace("%NAME%",$personsName,$body); $body = str_replace("%SITENAME%",$siteName,$body); [/code] [/quote]
  11. This is a bit interesting.. I have two files: 1. The script to gather all of the email addresses and gets the data that is going to be included in the template. 2. The template of the email which includes php variables I have done it this way because I want to keep my email template separate from the code all of the data that i want to email is included in mailer_template.php. You would think hey this is easy.. set $message = file_get_contents('mailer_template.php'); and then just type mail("$email","$subject","$message","$headers"); but that doesnt work because there are php variables inside mailer_template.php (that arent getting displayed in the emails). the goal here is to have mailer_template.php to be able to include php variables how do you assign mailer_template.php to the variable $message so that it still includes data from the database?
  12. how long did it take you to know as much as you do? I cant wait until i get there! Thanks a lot for the bit of knowledge!
  13. how can it tell if the script is called by me or a header location ?? header("Location: $_SERVER[PHP_SELF]?lets_do_this=1&start=$start&redirect_number=$_GET[redirect_number]"); ok lets see how this would work.. $auto_refer = $_SERVER["HTTP_REFERER"]; if(!isset($auto_refer)){ } then what are you saying exactly? [!--quoteo(post=369047:date=Apr 26 2006, 06:20 PM:name=Koen Calliauw)--][div class=\'quotetop\']QUOTE(Koen Calliauw @ Apr 26 2006, 06:20 PM) [snapback]369047[/snapback][/div][div class=\'quotemain\'][!--quotec--] just for future reference: you can check if $_SERVER["HTTP_REFERER"] is empty (only if the script is called directly), then it is the first time, otherwise, it is not. If the script is not called directly, check what $_SERVER["HTTP_REFERER"] is and compare it to what it returns each time you call the page. [/quote]
  14. nope didnt work see whats happening is that after i run the script, it adds $start and $redirect_number to the URL... this $start & $redirect_number values are staying with the page! i need to some how empty them but only if it is the script is being run for the first time the script refrshes every 50 records to assure that the page doesnt time out, so we need these variables through out the time that it refreshes then once its done, i would love to kill the variables do you know how to empty variables so they arent set to anything? I could prob do that at the end of the script hey that was a simple solution! thank you! what i did was just emptied the variables after the code, and then ran it 5 or 6 times to clear out the cache man internet explorer can be horrible some times! Thanks a lot for the help!!
  15. ok it turns out, the problem was with my browser. see what happens is whenever you refresh on internet explorer for some reason it doesnt refresh all the time every time do you guys know of a way to force your browser to check to see if the file has been updated, even if it is just 1 character? thanks for the info guys!
  16. This is just a sniplet from a much larger piece of code. When I run this, it places the last successfull user_id into the tmp_mail_count table so we can keep track of what member to start off with next (because browsers time out). For example. if there are 80 records, it will redirect 1 time, leaving 30 that still need to process, and so on... I think the problem is that $i must = 50 before it places all the data into the database at once.. how can we place the user_id into the database after each single iteration? instead of waiting until $i = 50 each time. [code] $_GET[start]; $_GET[redirect_number]; $number_per_load = 50; $sql_3 = " INSERT INTO `tmp_mail_count` VALUES ('$user_id') "; $result_3 = mysql_query($sql_3); //$connect1->sendmail($row_2['user_email'],"$subject","$message[$i]","$headers"); $i++; if ($i == $number_per_load)  { $start += $number_per_load; $_GET['redirect_number']++; if ($_GET['redirect_number'] > 10)  { header("Location: mailer_test.php?lets_do_this=1&start=$start"); }else { header("Location: $_SERVER[PHP_SELF]?lets_do_this=1&start=$start&redirect_number=$_GET[redirect_number]"); } } [/code]
  17. [!--quoteo(post=368997:date=Apr 26 2006, 05:02 PM:name=4bidden)--][div class=\'quotetop\']QUOTE(4bidden @ Apr 26 2006, 05:02 PM) [snapback]368997[/snapback][/div][div class=\'quotemain\'][!--quotec--] Maybe I should simplify what I'm asking.... I am getting a variable such as January 24-27, 2006 fed to me from mySQL, but sometimes I will need to subtract one day from the end making it January 24-26, 2006. I also have available to me the start date and end date in datetime format such as 2006-01-24 00:00:00. How about this. How can I do math on two dates formatted in mysql datetime in PHP? [/quote] ahhh good question here is some code i was working with just a few weeks agao.. hopefully it is displayed nice.. anyways its exactly what you want. just assign $date_today variable the variable that you are retrieving from your database.. and where i use 6 days, you would use 1 in your case... its a pretty nifty snipplet of code //Get current time and split into its individual units $date_today = date('Y-m-d'); $dateSplit = explode("-",$date_today); $year = $dateSplit[0]; $month = $dateSplit[1]; $day = $dateSplit[2]; //Next put these date parts into the mktime function to generate a unix time stamp $timestamp = mktime(0,0,0,$month,$day,$year); //Calculate the # of seconds in a day then Multiply by the days that we want $oneDay = 24 * 60 * 60; $total = 6 * $oneDay; $newTimestamp = $timestamp - $total; //Convert our new timestamp back to our original date format with date() $start_time = date("Y-m-d",$newTimestamp); //echo $start_time; [!--quoteo(post=369002:date=Apr 26 2006, 05:17 PM:name=darga333)--][div class=\'quotetop\']QUOTE(darga333 @ Apr 26 2006, 05:17 PM) [snapback]369002[/snapback][/div][div class=\'quotemain\'][!--quotec--] ahhh good question here is some code i was working with just a few weeks agao.. hopefully it is displayed nice.. anyways its exactly what you want. just assign $date_today variable the variable that you are retrieving from your database.. and where i use 6 days, you would use 1 in your case... its a pretty nifty snipplet of code //Get current time and split into its individual units $date_today = date('Y-m-d'); $dateSplit = explode("-",$date_today); $year = $dateSplit[0]; $month = $dateSplit[1]; $day = $dateSplit[2]; //Next put these date parts into the mktime function to generate a unix time stamp $timestamp = mktime(0,0,0,$month,$day,$year); //Calculate the # of seconds in a day then Multiply by the days that we want $oneDay = 24 * 60 * 60; $total = 6 * $oneDay; $newTimestamp = $timestamp - $total; //Convert our new timestamp back to our original date format with date() $start_time = date("Y-m-d",$newTimestamp); //echo $start_time; [/quote] you will notice that the way i had it i used subtraction.. you can use addition to add and get future dates, etc.. the only reason taht it needs to go to the unix timestamp is so it can get the exact time in seconds... then subtract how ever many days in seconds.. if you really look at it it should be self explanitory. hope that helps!
  18. [!--quoteo(post=368956:date=Apr 26 2006, 03:12 PM:name=4bidden)--][div class=\'quotetop\']QUOTE(4bidden @ Apr 26 2006, 03:12 PM) [snapback]368956[/snapback][/div][div class=\'quotemain\'][!--quotec--] Here is the situation. I have a mySQL database that has a starttime field (datetime), endtime field (datetime), coursecode field (GPR4 for example) and a nice pretty field that has the dates already formatted like December 28-30, 2006. The database is a listing of all available events occuring at our facility. I am displaying the available dates on the web. I figured I'd make it easy on myself and use the pre-formatted field BUT I forgot something. We have a course called GPR3 and GPR4 (the 3 and 4 refering to a 3 and 4 day course). The GPR3 dates are all GPR3 and GPR4 dates (they just do the first 3 days). So when I select all the info with rows containing both coursecodes, the nice and pretty pre-formatted column still shows the course running 4 days. So my output is looking like this. Available GPR3 dates: May 22-25, 2006 June 5-8, 2006 June 19-22, 2006 June 26-28, 2006 July 5-7, 2006 July 10-13, 2006 As you can see, most of the dates are GPR4 dates and therefore show the course running 4 days. So how should I go about fixing this. The startdate field returns format YYYY-MM-DD 00:00:00. The logic basically needs to go if(enddate - startdate > 3) { enddate--; } And then I can work with it from there. I'm just lost as to what transformations (and how) to do on the datetime format from sql to get there. Thanks in advance for all help!!! [/quote] I dont know exactly what you are trying to do. If all it is is to get two different sets of dates, one the GPR4 and one the GPR3.. all you need to do is two diff queries.. //$coursecode is the GPR variable.. so if you create a form to pull up the dates you will use 'coursecode' as the name of the input field.. ex. Select a GPR type: <SELECT NAME="coursecode"> <OPTION VALUE="GPR3"> GPR3 <OPTION VALUE="GPR4"> GPR4 <OPTION VALUE="GPR5"> GPR5 </SELECT> //Then your form processing page should have this code.. tablename being the name of the table you are storing your data in $coursecode = $_POST[coursecode]; $sql = "SELECT * FROM tablename WHERE coursecode = '$coursecode' "; $result = mysql_query($sql); $num_rows = mysql_num_rows($result); if ($num_rows > 0){ while $row = mysql_fetch_array($result){ echo "Starttime is:".$row['starttime']; echo "Endtime is:$row['endtime']; echo "Pretty date is:$row['prettydatefield']; } } Remember when getting certain results to display, its always in the SQL query... I hope this helps! I'm a newbie so there might be some php syntax error
  19. [!--quoteo(post=368949:date=Apr 26 2006, 02:54 PM:name=Orio)--][div class=\'quotetop\']QUOTE(Orio @ Apr 26 2006, 02:54 PM) [snapback]368949[/snapback][/div][div class=\'quotemain\'][!--quotec--] This is what you need: $msg=file_get_contents(template.php); [a href=\"http://www.php.net/manual/en/function.file-get-contents.php\" target=\"_blank\"]http://www.php.net/manual/en/function.file-get-contents.php[/a] [/quote] orio you are the man! thnx!! [!--quoteo(post=368952:date=Apr 26 2006, 02:58 PM:name=darga333)--][div class=\'quotetop\']QUOTE(darga333 @ Apr 26 2006, 02:58 PM) [snapback]368952[/snapback][/div][div class=\'quotemain\'][!--quotec--] orio you are the man! thnx!! [/quote] problem!! when i do that, it gets the file contents, but it doesnt include the php thats inside of it as an include would, any solutions? [!--quoteo(post=368952:date=Apr 26 2006, 03:01 PM:name=darga333)--][div class=\'quotetop\']QUOTE(darga333 @ Apr 26 2006, 03:01 PM) [snapback]368952[/snapback][/div][div class=\'quotemain\'][!--quotec--] orio you are the man! thnx!! problem!! when i do that, it gets the file contents, but it doesnt include the php thats inside of it as an include would, any solutions? [/quote] what i mean by that is I have php variables inside that mail template, the variables in that mail template that i am including are determined by the file that i put the include statement in for instance... /* some php here *\ $message=file_get_contents('mailer_template.php'); echo $message; ... it just spits out the same $message include works, but it wont let me assign a variable to it like this $message = include('mailer_template.php');
  20. ex. $message = include('template.php'); then i can send the $message variable to the mail(); function thank you! darga333
  21. I just learned about mysql_real_escape_string and stripslashes. This is ofcourse to prevent SQL injection and any other type of malicious activity that experienced hackers could break. The question: I use the mysql_real_escape_string right after I receive the POST variables. Is this the best way to prevent malicious activity through the forms? I use the stripslashes right before display stuff to the users. Is this the best way? And is there anything else that developers should be aware of to ALWAYS include in our scripts? We want to learn the best coding techniques and I thought you guys might have some input on this.
  22. hey thats pretty neat! I am going to have to do that from now on.. thanks for the hand!
  23. Hey! I just figured it out, you have to make the very first SQL statement a GROUP BY instead of an ORDER BY... That took over 8 hours of guessing and checking to figure out. I really want to be a PHP guru and a javascript guru.. i am just a beginner.. but thanks for the compliment! the hardest things to me are loops, for each loops, and any other loop you can think of, they are a pain in the ass. and oh yeah that error that says something like not a valid mysql resource, that one is truely a pain! some stuff i just dont understand about coding yet but I appreciate the help! ohhh hey!! maybe you might know something about this comma thing.. whenver you try to update data if the data contains one or more commas... oh boy a huge problem.. every single time mysql stops on the comma and dies.. i had to fix a good 100 things by hand.. .. i would run the script, it would die, then i would get the id of where it died.. then i would find all the commas,.. then i would put a \ before the comma.. then run again... then dies... repeat.. lol there has got to be a way to run a query to get all of the information even with commas... or run a query then get all of the data.. then write a snipplet of code to put a \ before each comma, so mysql can be happy... you know anything about this?
  24. Im sorry but I dont understand what you are saying. I tried commenting out that while loop, but then it doesnt display anything. If i remove the code inside that while loop, then the discounts arent displayed on the page. The first query works fine. It selects all the user_id's that i need. Then the second query is suposed to get all the discounts for that user_id and print them all on the screen. I think I have something seriously messed up with my code because when it finds more than 1 discount for a user, it displays all the discounts but multiple times. For example. If there is 2 discunts, it will display 2 discounts, but twice. I have no idea what I am doing. Could you please be more descriptive on what I need to do. I am very much new to programming.
  25. Hi there! I am new to PHP and am having trouble with this loop. For some reason, when everything is outputted... it works perfectly if there is only 1 record that is returned in the $sql_1 statement... The problem is when the $sql_1 statement returns more than one record, it displays the $discount_message twice. The real problem is that $discount_message already contains both the discounts it found.. so there is no need to display both discounts again. Please help!! [code]     $sql_0  = " SELECT  `user_id`,`sRepresentatives` FROM  `ucfmembers`,`ucfdiscount` WHERE ucfmembers.user_id=ucfdiscount.iMemberId AND ucfmembers.bBusiness =1 AND ucfdiscount.sActive=1 AND ucfdiscount.sFeatured=1 ORDER  BY ucfmembers.user_id ASC ";     $result_0 = mysql_query($sql_0);     while($row_0 = mysql_fetch_array($result_0))  {     $discount_message = "";     $user_id = $row_0['user_id'];     $rep = $row_0['sRepresentatives'];                   $sql_1  = " SELECT *,ucfdiscountcategory.sName,ucfdiscount.sDescription FROM `ucfdiscount`,ucfdiscountcategory WHERE ucfdiscount.sActive = 1 AND ucfdiscount.sFeatured = 1 AND ucfdiscount.iDisCategoryId = ucfdiscountcategory.idiscategoryid AND ucfdiscount.iMemberId=$user_id";                          $result_1 = mysql_query($sql_1);                                       if (mysql_num_rows($result_1) > 0) {             while($row_1 = mysql_fetch_array($result_1))  {                                                   //$current_catid = $row_1['iDisCategoryId'];                 $discount_message .= "<h2>".$row_1['sName']."</h2>";                 $discount_message .= "<p><strong>".$row_1['sBusinessName']."</strong><br>\n";                 $discount_message .= $row_1['sHeadlines']."<br>\n";                 $discount_message .= $row_1[1]."<br>\n";                 $discount_message .= $row_1['sDescription']."<br>\n";                 $discount_message .= $row_1['sPhone']."<br>\n";                 $discount_message .= "<a href=\"http://www.ucflife.com/viewcoupon.php?id=".$row_1['idiscountid']."\">View your coupon!</a>";                 //echo $current_catid;                              }                  }     echo "<br />This is discount message OUTSIDE OF THE LOOP: ".$discount_message."<br /><br />";             echo $rep;     }          echo "<h1>You are Done!</h1>"; [/code]
×
×
  • 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.