Web Analytics Made Easy -
StatCounter Getting Value From Database - CodingForum

Announcement

Collapse
No announcement yet.

Getting Value From Database

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting Value From Database

    to all,
    i am not sure how to retrieve a value from the database. ok, i am suppose to put a value into my mailing code. here's part of the code:

    PHP Code:
    if ($numRows){
        
    $sqlTxt 'SELECT password FROM tblMembers WHERE password = \''.$_POST["txtConUser"].'\'';
        
    $rs mysql_query($sqlTxt);
        
    //$numRows = mysql_num_rows($rs);
        
    /*Member successfully created, send the activation mail now    */
                            
    $mail = new as_Mail();
                            
    $mail->to $_POST["txtConEmail"];
                            
    $mail->from "[email protected]{$_SERVER['SERVER_NAME']}.com";
                            
    $mail->cc "[email protected]";
                            
    $mail->bcc "[email protected]";
                            
    $mail->subject "**BULK** Your Password For Halo Account!";
                            
    $myMsg "This is the time this <b>mail</b> was generated: " date("F j, Y, g:i a") .
                                 
    "<br>This Is Your Password To The Kote Account" .
                                 
    "<br>Your Password : " ;
                            
    $mail->body $myMsg;
                            
    $mail->rigorous_email_check false
    emphasize is on "<br>Your Password : "; what's the code to retrieve the value from my database to put it there?

    pls help
    Warm Regards,
    Mivec

  • #2
    to all,
    is it this?

    PHP Code:
    $sqlTxt 'SELECT password FROM tblMembers WHERE password = \''.$_POST["txtConUser"].'\'';
        
    $rs mysql_query($sqlTxt);
        
    //$numRows = mysql_num_rows($rs);
        
    $getObject mysql_fetch_object($rs);
                .
                .
                .

    "<br>Your Password : $getObject
    pls help.thanks
    Warm Regards,
    Mivec

    Comment


    • #3
      It's been a little while for me, but...

      first of all, I don't think your query string looks proper. The single quotes looks kind of weird to me. This is how I think it should look:

      PHP Code:
       $sqlTxt "SELECT password FROM tblMembers WHERE password = ".$_POST['txtConUser']."; 
      Now one other thing you may want to consider is that more than one person in your database could have the same password. I think you should include the username in your WHERE clause.

      As far as getting the password out of the result set ($rs), you should do something similar to the following:

      PHP Code:
      while ($row mysql_fetch_array($rs)) {
       
      $myMsg .= "<br>Your Password : $row[0]";

      If you had more columns in your SELECT, they would be at $row[0], $row[1], ...

      Hope that helps,
      Sadiq.

      Comment


      • #4
        Originally posted by mivec
        to all,
        is it this?

        PHP Code:
        $sqlTxt 'SELECT password FROM tblMembers WHERE password = \''.$_POST["txtConUser"].'\'';
            
        $rs mysql_query($sqlTxt);
            
        //$numRows = mysql_num_rows($rs);
            
        $getObject mysql_fetch_object($rs);
                    .
                    .
                    .

        "<br>Your Password : $getObject
        pls help.thanks
        Been a while since I done this, but I think it should be obtained by

        $getObject -> password;

        Comment

        Working...
        X