Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts

    Question html email variables?

    How to get this into variable?
    PHP Code:
    <?php echo $row['code']; ?>
    This should work;
    PHP Code:
    echo $code
    Mine isn't working - how to fix this?
    PHP Code:
    while ($row = mysql_fetch_assoc($result)) {
    <table width="600" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="120" rowspan="5" nowrap="nowrap"><div align="center"><img src="uploads/<?php echo $row_rswish['thumb']; ?>" alt="" width="50" border="0" /></div></td>
      <td>&nbsp;</td>
      <td nowrap="nowrap">&nbsp;</td>
    </tr>
    <tr>
      <td><?php echo $row_rswish['code']; ?>
          <input name="code<?php echo $x?>" type="hidden" id="code" value="<?php echo $row_rswish['code']; ?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><?php echo $row_rswish['description']; ?>
          <input name="description<?php echo $x?>" type="hidden" id="description" value="<?php echo $row_rswish['description']; ?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><?php echo $row_rswish['diamondinfo']; ?>
          <input name="diamondinfo<?php echo $x?>" type="hidden" id="diamondinfo" value="<?php echo $row_rswish['diamondinfo']; ?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><?php echo $row_rswish['price']; ?>
          <input name="price<?php echo $x?>" type="hidden" id="price" value="<?php echo $row_rswish['price']; ?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
    <td colspan="3" valign="top" nowrap="nowrap"><hr>
    <input name="------------------------<?php echo $x?>" type="hidden" value="------------------------" /></td>
    </tr>
    <tr>
      <td valign="top" nowrap="nowrap">&nbsp;</td>
    <td valign="top" nowrap="nowrap">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" nowrap="nowrap">&nbsp;</td>
    <td valign="top" nowrap="nowrap">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    }
    All this has to do is loop and send.
    I am using this for email part;
    PHP Code:
    <?php 
    function send_email($to=''$from=''$subject=''$html_content=''$text_content=''$headers='') { 
    # Setup mime boundary
    $mime_boundary 'Multipart_Boundary_x'.md5(time()).'x';

    $headers  "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\r\n";
    $headers .= "Content-Transfer-Encoding: 7bit\r\n";

    $body "This is a multi-part message in mime format.\n\n";

    # Add in plain text version
    $body.= "--$mime_boundary\n";
    $body.= "Content-Type: text/plain; charset=\"charset=us-ascii\"\n";
    $body.= "Content-Transfer-Encoding: 7bit\n\n";
    $body.= $text_content;
    $body.= "\n\n";

    # Add in HTML version
    $body.= "--$mime_boundary\n";
    $body.= "Content-Type: text/html; charset=\"UTF-8\"\n";
    $body.= "Content-Transfer-Encoding: 7bit\n\n";
    $body.= $html_content;
    $body.= "\n\n";

    # Attachments would go here
    # But this whole email thing should be turned into a class to more logically handle attachments, 
    # this function is fine for just dealing with html and text content.

    # End email
    $body.= "--$mime_boundary--\n"# <-- Notice trailing --, required to close email body for mime's

    # Finish off headers
    $headers .= "From: $from\r\n";
    $headers .= "X-Sender-IP: $_SERVER[SERVER_ADDR]\r\n";
    $headers .= 'Date: '.date('n/d/Y g:i A')."\r\n";

    # Mail it out
    return mail($to$subject$body$headers);
    }
    ?>
    <?php
    send_email
    ($to='email'$from='email'$subject='My Wishlist'$html_content=$message$text_content='My Wishlist'$headers='From:$from \r\n')
    ?>
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Try:

    PHP Code:
    $code $row['code']; 
    I know that's not what you want to do, but you really need to get away from relying on register_globals being turned on. It's been deprecated a long time and will be completely absent from PHP 6. Quit assuming you'll have those variables available.

  • Users who have thanked Fumigator for this post:

    student101 (08-04-2008)

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Not sure what you're asking, but
    while ($row = mysql_fetch_assoc($result)) {
    <table width="600" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="120" rowspan="5" nowrap="nowrap"><div align="center"><img src="uploads/<?php echo $row_rswish['thumb']; ?>" alt="" width="50" border="0" /></div></td>
    <td>&nbsp;</td>
    <td nowrap="nowrap">&nbsp;</td>
    </tr>
    ...............
    what's $row_rswish ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts
    I am trying my utmost to send an HTML email that has dynamic data based on IP address - BUT really can't get this going.

    As for register_globals; The HOST is using PHP 4.4.4 etch, not sure if that's the problem.
    I am testing on php 5.2.6.

    $row_rswish is the recordset.
    I posted the wrong recordset value it should be
    Code:
    <?php echo $row['thumb']; ?>
    and it's not working, busy changing all the variables to this;
    Code:
    $code = $row['code'];
    Last edited by student101; 08-04-2008 at 04:12 PM.
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:

  • #5
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts

    Question

    Using this gives the attached, it's not giving me that actual data.
    PHP Code:
    <?php 
    $name 
    $HTTP_GET_VARS['name'];
    ?>
    <?php
    //connection to the database
    $dbhandle mysql_connect($hostname$username$password) or die("Unable to connect to MySQL"); 
    //echo "Connected to MySQL<br>";
    //select a database to work with
    $selected mysql_select_db($myDB,$dbhandle) or die("Could not select db");
    //execute the SQL query and return records
    $result mysql_query("SELECT * FROM wishlist WHERE name = '$name'"); //WHERE name = $name");

    $thumb $row['thumb'];
    $code $row['code'];
    $description $row['description'];
    $diamondinfo $row['diamondinfo'];
    $price $row['price'];

    ?>
    <?php 
    echo '<!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></title>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <table width="600" border="0" cellpadding="5" cellspacing="0">
    <tr>
    <th rowspan="2" align="center" scope="col"><img src="img/situlogotop.jpg" width="292" height="100" /></th>
    <th height="65" scope="col"><div align="center"><span class="parab"> Wishlist </span><img src="img/mini-pink-heart.gif" width="20" /> </div></th>
    </tr>
    <tr>
    <td height="22">list</td>
    </tr>
    </table>'
    ;
    ?>
    <?php
    while ($row mysql_fetch_assoc($result)) {
    ?>
    <?php 
    echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="120" rowspan="5" nowrap="nowrap"><div align="center"><img src="uploads/$thumb" alt="" width="50" border="0" /></div></td>
      <td>&nbsp;</td>
      <td nowrap="nowrap">&nbsp;</td>
    </tr>
    <tr>
      <td><?php echo $code; ?>
          <input name="code<?php echo $x; ?>" type="hidden" id="code" value="<?php echo $code; ?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><?php echo $description; ?>
          <input name="description<?php echo $x; ?>" type="hidden" id="description" value="<?php echo $description; ?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><?php echo $diamondinfo; ?>
          <input name="diamondinfo<?php echo $x; ?>" type="hidden" id="diamondinfo" value="<?php echo $diamondinfo; ?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><?php echo $price; ?>
          <input name="price<?php echo $x; ?>" type="hidden" id="price" value="<?php echo $price; ?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
    <td colspan="3" valign="top" nowrap="nowrap"><hr>
    <input name="------------------------<?php echo $x; ?>" type="hidden" value="------------------------" /></td>
    </tr>
    <tr>
      <td valign="top" nowrap="nowrap">&nbsp;</td>
    <td valign="top" nowrap="nowrap">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" nowrap="nowrap">&nbsp;</td>
    <td valign="top" nowrap="nowrap">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>'
    ;
    ?>
    <?php
    }
    mysql_close($dbhandle);
    ?>
    If I do it this way without the echo and the full <?php echo $row['thumb']; ?>then it works for viewing only but not emailing.

    PHP Code:
    <?php 
    $name 
    $HTTP_GET_VARS['name'];
    ?>
    <?php
    //connection to the database
    $dbhandle mysql_connect($hostname$username$password) or die("Unable to connect to MySQL"); 
    //echo "Connected to MySQL<br>";
    //select a database to work with
    $selected mysql_select_db($myDB,$dbhandle) or die("Could not select db");
    //execute the SQL query and return records
    $result mysql_query("SELECT * FROM wishlist WHERE name = '$name'"); //WHERE name = $name");

    $thumb $row['thumb'];
    $code $row['code'];
    $description $row['description'];
    $diamondinfo $row['diamondinfo'];
    $price $row['price'];

    ?>
    <!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></title>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <table width="600" border="0" cellpadding="5" cellspacing="0">
    <tr>
    <th rowspan="2" align="center" scope="col"><img src="img/situlogotop.jpg" width="292" height="100" /></th>
    <th height="65" scope="col"><div align="center"><span class="parab"> Wishlist </span><img src="img/mini-pink-heart.gif" width="20" /> </div></th>
    </tr>
    <tr>
    <td height="22">list</td>
    </tr>
    </table>
    <?php
    while ($row mysql_fetch_assoc($result)) {
    ?>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="120" rowspan="5" nowrap="nowrap"><div align="center"><img src="uploads/<?php echo $row['thumb']; ?>" alt="" width="50" border="0" /></div></td>
      <td>&nbsp;</td>
      <td nowrap="nowrap">&nbsp;</td>
    </tr>
    <tr>
      <td><?php echo $code?>
          <input name="code<?php echo $x?>" type="hidden" id="code" value="<?php echo $row['$code']; ?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><?php echo $description?>
          <input name="description<?php echo $x?>" type="hidden" id="description" value="<?php echo $description?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><?php echo $diamondinfo?>
          <input name="diamondinfo<?php echo $x?>" type="hidden" id="diamondinfo" value="<?php echo $diamondinfo?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><?php echo $price?>
          <input name="price<?php echo $x?>" type="hidden" id="price" value="<?php echo $price?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
    <td colspan="3" valign="top" nowrap="nowrap"><hr>
    <input name="------------------------<?php echo $x?>" type="hidden" value="------------------------" /></td>
    </tr>
    <tr>
      <td valign="top" nowrap="nowrap">&nbsp;</td>
    <td valign="top" nowrap="nowrap">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" nowrap="nowrap">&nbsp;</td>
    <td valign="top" nowrap="nowrap">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    <?php
    }
    mysql_close($dbhandle);
    ?>
    Last edited by student101; 06-13-2009 at 09:44 PM.
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    How do you expect a value in $row array before assigning something to it?
    PHP Code:
    $thumb $row['thumb'];
    $code $row['code'];
    $description $row['description'];
    $diamondinfo $row['diamondinfo'];
    $price $row['price']; 
    should be after
    PHP Code:
    <?php
    while ($row mysql_fetch_assoc($result)) {
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    student101 (08-04-2008)

  • #7
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts
    WORKING THANK YOU!!!

    What I didn't see, I see now!

    Thank you!!!
    Last edited by student101; 08-04-2008 at 06:30 PM.
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •