help me!! pls!! basic mysql problem... :(

Discussion in 'MySQL' started by pambo, Dec 8, 2007.

  1. #1
    Hi,
    i used php to display some data from a mysql database.... however i need to send this data to a certain email.... any ideas? the data is shown in a dynamic table made using a recordset in dreamweaver.... here is the code im using:

    <?php require_once('Connections/MySQL_database.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
    
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    }
    
    mysql_select_db($database_MySQL_database, $MySQL_database);
    $query_getdata = "SELECT referencia, priceunit, quantity, colour, pricefinal FROM populate ORDER BY referencia ASC";
    $getdata = mysql_query($query_getdata, $MySQL_database) or die(mysql_error());
    $row_getdata = mysql_fetch_assoc($getdata);
    $totalRows_getdata = mysql_num_rows($getdata);
    
    ?>
    <table border="1">
      <tr>
        <td><div align="center"><strong>referencia</strong></div></td>
        <td><div align="center"><strong>priceunit</strong></div></td>
        <td><div align="center"><strong>quantity</strong></div></td>
        <td><div align="center"><strong>colour</strong></div></td>
        <td><div align="center"><strong>pricefinal</strong></div></td>
      </tr>
      <?php do { ?>
        <tr>
          <td><?php echo $row_getdata['referencia']; ?></td>
          <td><?php echo $row_getdata['priceunit']; ?></td>
          <td><?php echo $row_getdata['quantity']; ?></td>
          <td><?php echo $row_getdata['colour']; ?></td>
          <td><?php echo $row_getdata['pricefinal']; ?></td>
        </tr>
        
        
       <?php } while ($row_getdata = mysql_fetch_assoc($getdata));   
     ?>
    </table>
    
    <?php 
    
    $mailto = 'jason.vision@gmail.com' ;
    $thankyouurl = "http://www.bythemusic.pt/redesign/obrigado.shtml" ;
    $subject = "SUBJECT" ;
    $formurl = "http://cartune.pt/mainTEST1.php" ;
    $errorurl = "http://www.bythemusic.pt/redesign/formularioespectaculosError.shtml" ;
    
    $messageproper =
    
    	
    	
    	"-----------------------------------------------------------------------------------------------------------\n\n" .
    	"REFERENCE:$row_getdata2\n".
    	"Colour selected:row_getdata['colour']\n" .
    	"Quantity:row_getdata['quantity']\n".
    	"Final Price:row_getdata['pricefinal']\n\n".
    
    	"\n\n---------------------------------------------------------------------------------------------------------------\n" ;
    
    	
    	mail($mailto, $subject, $row_getdata['referencia',1],
    	"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "" );
    header( "Location: $thankyouurl" );
    
    ?>
    
    
    
    <?php
    
    mysql_free_result($getdata);
    ?>
    
    
    Code (markup):

     
    pambo, Dec 8, 2007 IP
  2. urstop

    urstop Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Code looks fine. But I think you should be sending $messageproper in the mail instead of $row_getdata['referencia',1].
     
    urstop, Dec 9, 2007 IP