Jump to content

phporcaffeine

Members
  • Posts

    361
  • Joined

  • Last visited

    Never

Posts posted by phporcaffeine

  1. Script sends out text/plain email using php's mail() construct .... all working fine. However, I had a user use Novell GroupWise to receive an email and it chops the formatting up pretty hard.

     

    Specifically, any \r\n characters are translated into =09=0D=0A and carriage returns are replaced with =5F=5F

     

    Right now, I am setting UTF-8 in the mail header, anyone know of a better, more universally accepted charset?

  2. Well, your code says that if mysql_affected_rows() != (does not equal) 1, then it will use the header url of the one you specified. So that indicates mysql_affected_rows() is not equaling 1, when you think it should be.

     

    Ask yourself why that is?

     

    TIP: mysql_query($sql) or die(mysql_error());

  3. I read the doc in 5 secs there was nothing of this sort where i can append the attribute of the first sql queryset.

    I guess no 1 has tried this ever b4!!!

     

    Although I will tell you that reading any sort of manual in 5 seconds is utterly preposterous and that I think your statement about no one ever having tried this before is rude and absurd (considering the heavyweight attention your post has got from some seriously sick LAMP (that's, Linux, Apache, MySQL and PHP) pros); I'll give you the answer (to your specific question, not that it is the best way to do it) just to satisfy myself.

     

    $sql2="SELECT attrb2 fromt table2 where attrb3=".$sql[attrb1];
    

     

    You had a period, at the end, right before the semi-colon.  I knew that because I have tried this before, thousands of times perhaps.

     

  4. Why not use the str_repeat function instead?

     

    Sure, that works too. I always try to stick to the OP's logic as much as possible - unless it's a blatant syntax violation or they have specifically asked for alternatives. Your suggestion implements the solution in more of a PHP way of doing things while the double loop scenario is more of a language agnostic way of doing things.

     

    Admittedly, this is a PHP forum, so one should expect answers to be language biased. Either way, both solutions would work just fine.

  5. It is not possible to extend multiple classes; a class can only inherit from one base class. So in your illustration, you're trying to get the root class to extend the properties of both a and b?

     

    You could do it this way:

     

    Base Class
        |
    Class A
        |
    Class B
        |
    Root Class
    

     

    Perhaps you could use some conditional logic to determine which class (a or b) to load? If the methods are similar, could you combine them or use logic to change the behaviors of the methods and eliminate the need for one of the classes altogether.

  6. Hey, I appreciate the offer, I really do, but look from my perspective, you say "personally I don't care about what is in your database", you're right, but a couple clicks, and the entire db is wiped out, I'm not saying you'd do that, but allowing someone access your db from a help forum, in my mind, is ludicrous.

     

    I would have expected you to replicate the database that your trying to connect to into another database and put me in that one; I wouldn't let anyone in my LIVE database either.

  7. Spent about 20-30min on this and I am kinda frustrated why I cant get this to work lol. Some help would be appreciated

     

    Admittedly, not sure why you would want to ... but here you go:

     

    <?php
    for ($row = 10; $row > 0; $row--) {
    	for ($cnt = 0; $cnt < $row; $cnt++) {
    		$star .= "*";
    	}
    	echo $star . "<br />";
    	$star = NULL;
    }
    ?>
    

     

    Now, if you want the stars to go the other direction (1-10 instead of 10-1), just flip the direction in which the variables are evaluated.

  8. Purely because I am curious why this wouldn't be working; if you want to PM me some credentials, I have some time to take a look personally.

     

    I appreciate that. Everything that I have is in this thread, the code, and screen shots of the db.

    If you're asking for credentials to log in to the db, that, I cannot do.

     

    Look, I understand about security ... etc - personally I don't care about what is in your database.

     

    Regardless, 'everything' that you have, that is posted here, obviously isn't working - so, you try something different. Maybe there is something that you think is irrelevant but is actually the reason it isn't working .... that's what I am getting at.

     

    The definition of insanity is doing the same thing, over and over, expecting different results each time.

     

    Hope it works out for you.

  9. While I do agree that you need to filter your request down a lot, I'll give you a little shove in the right direction.

     

    Start with the area that is echoing out TBA instead of what you think it should be. Why is that variable set to TBA instead of what it should be? Where is that variable set at?

     

    Most (if not all) diagnosticians think this way; reverse engineering. Start with the end (albeit undesired) result and work your way all the back to the beginning if needed. Its like doing a maze in reverse.

     

    Start with the answer and use it to figure out what the question is.

  10. You can attack that challenge from a number of ways; you could use client logic and organize the data with html, css and javascript, you could run a join query (depending on your table structure) and return everything in an associative array ... etc ... the list goes on.

     

    Generally, on this forum, you'll find a ready supply of folks (like myself and ManiacDan), highly skilled in LAMP technologies and web development; that are ready to donate their time and troubleshoot/diagnose problematic code or misinformed developers (the latter seeming to be the more common encounter). However, posts that seem to solicit someone designing a solution for you, will usually get little to no attention.

     

    So, try a come up with a solution on your own; when/if it doesn't work or you can't figure out the code that you have written, post it here and we'll be more than happy to help. The goal is to teach and learn; you don't learn by having it done for you.

  11. I would use yahoo babblefish to translate your native language to English, before posting.

     

    The quick answer is no, PHP won't 'stream' MP3's, because PHP would have to have access to the user's sound hardware - that violates that nature of the client/server environment that PHP operates in.  You can do things like that with Flash or Java however.

     

    Now, if you just simply want to make a textual playlist in XML, start here: http://php.net/manual/en/book.xml.php

  12. 1.) Make sure that the database field is large enough to hold the serialized array. Serialized data is very space-inefficient in PHP, and many DBs (like MySQL) will silently truncate field values that are too long.

     

    2.) Make sure that you are not serializing a resource id / object (because they can't be serialized)

     

    3.) When saving serialized data, don't try and do anything to it other than escaping ( mysql_real_escape_string() )

  13. eMonk, did you look at your own code? After you have written some code, before you ever execute it, you need to 'play computer' and proof-read/step through your code, line by line, to make sure the logic you have written does what you want. You are accessing $row['expiry_date'] before you have even set $row. How would that ever work?

     

    However, you should never retrieve all the rows from a database table, then loop through them to find a matching condition. You would use a WHERE clause in your query to retrieve just the row(s) you are interested in. You also would never put an include statement for something like the pear mail class inside of a loop as that would redefine the class every pass through the loop. You would include the mail class one time near the start of your program.

     

    Yeah, I had hoped to get OP through some of the logic of the loop, before addressing the include in the loop.  It wouldn't work anyway, unless include_once was used .... regardless, not needed either way. I figured, once I got OP to figure out how to fix the loop then he/she would 'discover' that including the same class, over and over, in a loop wouldn't work, once it started throwing errors.

  14. http://www.phpfreaks.com/forums/index.php?topic=347969.msg1642112#msg1642112

     

    I've never been a fan of using PHP, natively, for mass emailing. Among many reasons; the typical mail server that PHP is set to use on an average third party hosted web server, is almost never, never setup the way you would wan't a mass emailing mail server to be setup.

     

    Maybe 3 -4 years ago, I would have spent the time to craft a solution but there are way too many alternatives available today. Additionally, with the CAN SPAM Act, it pays to use a service designed to handle mass mailing.

     

    Google:

     

    Constant Contact

    Aweber

    iContact

    MailChimp

  15. According to your snippet;

     

    In order to see "No results found", $expiration_date has to be LESS THAN $today - because anything else would fire the logic in the construct.

     

    So, is $expiration_date GREATER THAN $today? Are you sure you know what the values are that you are comparing? Have you dumped the variables to see what they are?

     

    Do you see "No results found" on every iteration of the loop (because the condition is evaluated with each iteration)?

     

    Also, it seems that you are only incrementing the loop limiter ($i) inside the construct, when $expiration_date is GREATER THAN $today, so when $expiration_date is not GREATER THAN $today, the loop limiter is not incremented. That could cause an endless loop, if $i never gets incremented to be GREATER THAN $num_results (which is what will stop the loop).

     

  16. Here is how the most basic of basic login scripts would look, using sessions:

     

    We'll call this index.html:

    <html>
    <head><title>Test</title></head>
    <body>
    <form name="loginFrm" id="loginFrm" action="login.php" method="post">
    Enter the secret code: <input type='password' name='code' id='code'> <input type='submit' name='send' id='send' value='Login'>
    </form>
    </body>
    </html>
    

     

    We'll call this login.php:

    <?php
    session_start();          //GOOD HABIT SAYS ALWAYS PUT THIS AT THE TOP, BEFORE ANYTHING ELSE
    
    if (isset($_POST['password'])) {
    
         if ( strtolower( trim( stripslashes($_POST['password']) ) ) === 'test') {
              $_SESSION['login'] = 'John Doe User';
         }
    
         else {
              die(session_destroy());
         }
    
    }
    
    if (isset($_SESSION['login'])) {
    
         print_r($_SESSION['login']);
    
    }
    
    ?>
    

     

    If you type in 'test' (no quotes) as the secret code, you'll see 'John Doe User' from login.php, anything else and you won't see anything.

     

    *NOTE*

    The above html page and php script is a DEMO, to help you understand the basics. It is not suited to use in an actual production system, but will suffice for getting your head around the basics.

     

    To answer your other question:

     

    index.php?action=home

     

    As far as PHP is concerned; the above is part of a url, everything to the right of '?' are key/value pairs in the GET namespace. So, if the page 'index.php' were reached with this URL, the array element $_GET['action'] would hold the value 'home'.

     

     

     

×
×
  • 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.