PHP Login System with Admin Features

This forum was created to talk about the PHP Login System with admin features created by jpmaster77 on evolt's website


    Update boolean field to True

    Share
    avatar
    Admin
    Admin

    Number of posts : 18
    Registration date : 2007-05-12

    Update boolean field to True

    Post  Admin on Wed Feb 18, 2009 9:49 pm

    Submitted by mbrad on February 18, 2009 - 12:01.

    Thanks for taking the time to read my question. I have a page messages.php that has a table on it that is generated by php. The last column of the table has a button, that when clicked, should update the field MessageRead in the table tblMessages. I have this code, that creates the button. Each button has a unique name. frm=form
    Code:
    <$php
    echo "<frm action=\"process.php\" method=\"POST\"><input type=\"hidden\" name=\"specify\" value=\"" . $value . "\"><input type=\"hidden\" name=\"msgread" . $value . "\" value=\"" . $value . "\"><input type=\"submit\" name=\"read" . $value . "\" value=\"Read\" />";

    This is the code in my process.php page that I added: at the top:
    Code:
    <$php
    /* User submitted edit account form */    //***************************Added This**************************************
          else if(isset($_POST['msgread' . $_POST['specify']])){
            $this->procReadMessage();
          }

    And this is the function: fcn=function, scpt=script, alrt=alert
    Code:
    <$php
    //This is what should fire when the "Read" button is clicked    //***************************Added This**************************************
      fcn procReadMessage() {
       
      echo "<scpt>alrt ('hi2');</scpt>";
        //The next line returns 5, this is the last msgread row. It returns 5 regardless of which "Read" button you click on. Need to fix that.
        //need to refer to each row uniquely, not sure how to pass the name on as I have 'msgread' in the $_Post part.
      echo "<scpt>alrt ('" .$_POST['msgread' . $_POST['specify']]. "');</scpt>";
      $retval = $session->UpdateMessageRead($_POST['msgread' . $_POST['specify']]);
      } 

    This is the code in session.php fcn=function, scpt=script, alrt=alert
    Code:
    <$php
    //This should fire as a result of process.php        //***************************Added This**************************************
      fcn UpdateMessageRead ($messagenum) {
          echo "<scpt>alrt ('hi3');</scpt>";
            $database->updateMessageRead($messagenum);
       
      }

    and this is the code in my database.php fcn=function, scpt=script, alrt=alert
    Code:
    <$php
    //This should fire as a result of session.php          //***************************Added This**************************************
      fcn UpdateMessageRead($messagenum){
          $q = "UPDATE ".tblMessages." SET MessageRead = 1 WHERE tblMessageID = " . $messagenum;
          return mysql_query($q, $this->connection);

      } 

    I get as far as an Alert popping up with the number 5 in it, so that means that it is taking the last row of the table, and passing that value to the process.php page function procReadMessage(), and it's getting as far as calling the function $session->UpdateMessageRead() but does not get past that. So I have 2 problems, one, the $_Post is returning 5 instead of 1, as I am clicking on the first "Read" button (name="read1"), and I can't get the MessageRead boolean value to be updated to True (0). Any ideas? Brad
    avatar
    Admin
    Admin

    Number of posts : 18
    Registration date : 2007-05-12

    Re: Update boolean field to True

    Post  Admin on Wed Feb 18, 2009 9:58 pm

    messages.php

    Code:

    <?include("include/session.php")?>
    <html>
    <head>
    <title></title>

    </head>

    <body>
    <?

    $id = "1"; //mysql table id or row to change this must be a unique value
    $value = "value1";

    print <<< eoe
    <form action="process.php" method="post" target="buffer">
    <input type="hidden" name="id" value="{$id}" />
    <input type="hidden" name="submsgread" value="1" />
    <input type="submit" value="Mark as Read" />
    <span id="result{$id}" style="display: none; background: green;"></span></form>

    eoe;



    ?>

    <div style="display: none;"><iframe src="" name="buffer"></iframe></div>
    </body>
    </html>

    process.php
    Code:



    /* User have marked message */
          else if(isset($_POST['submsgread'])){
            $this->procReadMessage();
          }



    /**
     * process.php :: procReadMessage()
     *
     */
    function procReadMessage() {
    global $database;   


    $q = 'UPDATE `'.tblMessages.'` SET `MessageRead` = \'1\' WHERE `id` = '.$_POST['id'].' LIMIT 1;';
    $retval = $database->query($q);

    if($retval) {
    echo "<script>alert ('The item id: ".$_POST['id']." as been marked as read.');parent.document.getElementById(\"result".$_POST['id']."\").innerHTML = \"This item as been marked as read.\";parent.document.getElementById(\"result".$_POST['id']."\").style.display = \"inline\";</script>";
       
    } else {
    echo "<script>alert ('There was an error updatiing id:".$_POST['id']." as not been marked as read.');parent.document.getElementById(\"result".$_POST['id']."\").innerHTML = \"There was as an error marking this message as read.\";parent.document.getElementById(\"result".$_POST['id']."\").style.display = \"inline\";</script>";
       
    }
     
    }

    this is the easyer way I think to done what you have to do

    Just have one question do you have id's in your mysql table for tblMessages
    if not you will have to modified this proposal.
    avatar
    mbrad

    Number of posts : 42
    Registration date : 2009-02-19

    Re: Update boolean field to True

    Post  mbrad on Thu Feb 19, 2009 10:13 am

    Thank you so very very much for your help!

    My table tblMessages does have an AutoID field which is the index (unique ID). The field I'm updating is a boolean field though, and so this is not a unique field [MessageRead=Boolean].

    I think I understand what you are dong here. What I don't quite get is the use of the <iframe>. Why is that needed?

    Also, I haven't seen eoe before, what is that? I tried searching it, but didn't find anything. I do know what eof is (end of file)

    Thanks again,

    Brad
    avatar
    Fred-Eric

    Number of posts : 63
    Registration date : 2007-05-13

    Re: Update boolean field to True

    Post  Fred-Eric on Thu Feb 19, 2009 4:56 pm

    mbrad wrote:Thank you so very very much for your help!

    My table tblMessages does have an AutoID field which is the index (unique ID). The field I'm updating is a boolean field though, and so this is not a unique field [MessageRead=Boolean].

    I think I understand what you are dong here. What I don't quite get is the use of the <iframe>. Why is that needed?

    Also, I haven't seen eoe before, what is that? I tried searching it, but didn't find anything. I do know what eof is (end of file)

    Thanks again,

    Brad

    Yes the eoe is for end of file but you can write code using any string for the starting but at the end the string must be the same ex:

    Code:

    print <<< eof

    here you can add anything you like

    apostrophe, quote and the braket {} is use to isolate a variable

    {$var}

    eof;

    OR
    Code:

    $var <<< anythingHere

    jkhfd lkjhfl khslkfjhsd


    anythingHere;


    This way the code is more easy to read


    the iframe is use to send the request without reloading the page. you target your form to the process.php and the with javascript you do things to show the result of that request. It is one of my way to do things.

    if your unique field is index so just replace {$id} in my code provide with the table index field.
    avatar
    mbrad

    Number of posts : 42
    Registration date : 2009-02-19

    Re: Update boolean field to True

    Post  mbrad on Thu Feb 19, 2009 10:57 pm

    Awesome, makes sense.

    How do I get back to the messages.php page. the code runs, the table is upated etc. but the code just stays on the process.php page.

    I put in

    Code:

    header("Location: ".$session->referrer);

    after the else{} statement. That doesn't get me back to the messages.php page. From what I can tell, that's how the other funtions end in the process.php page, so I'm guessing that is what get's you back to the page you were on.

    ideas?

    Thanks again,

    Brad
    avatar
    Fred-Eric

    Number of posts : 63
    Registration date : 2007-05-13

    Re: Update boolean field to True

    Post  Fred-Eric on Fri Feb 20, 2009 4:30 pm

    Make sure you have set $session as global within the function procReadMessage and the header(); should work

    Code:
    function procReadMessage() {
    global $database, $session;   
    .
    .
    .
    .
    header("Location: " . $session->referrer);
    }

    But an other way is to use javascript to do the task.

    The main advantage is if the table doesn't update successfully it will just show an alert message saying that the mak message as read as been failed. alsi it will not reload the page. Why reloading the page if the request as not been mark as successfull?



    top.location.replace('messages.php');
    OR
    top.location.replace('{$session->referrer}');
    so the code will look like this:


    /**
    * process.php :: procReadMessage()
    *
    */
    function procReadMessage() {
    global $database, $session;


    $q = 'UPDATE `'.tblMessages.'` SET `MessageRead` = \'1\' WHERE `id` = '.$_POST['id'].' LIMIT 1;';
    $retval = $database->query($q);

    if($retval) {
    echo "<script>alert ('The item id: ".$_POST['id']." as been marked as read.');parent.document.getElementById(\"result".$_POST['id']."\").innerHTML = \"This item as been marked as read.\";parent.document.getElementById(\"result".$_POST['id']."\").style.display = \"inline\";top.location.replace('" . $session->referrer . "');</script>";

    } else {
    echo "<script>alert ('There was an error updatiing id:".$_POST['id']." as not been marked as read.');parent.document.getElementById(\"result".$_POST['id']."\").innerHTML = \"There was as an error marking this message as read.\";parent.document.getElementById(\"result".$_POST['id']."\").style.display = \"inline\";</script>";

    }

    }
    avatar
    mbrad

    Number of posts : 42
    Registration date : 2009-02-19

    Re: Update boolean field to True

    Post  mbrad on Sun Feb 22, 2009 7:20 pm

    Ok, thanks to your help, I think I'm getting the hang of this!! Thanks so much for that.

    I'm trying to use a new form to add a New message to the DB, instead of updating an existing message.

    I can get error reporting to work, but I can't get the message to be added to the database. I think I'm really close, but I don't see what I'm doing wrong.

    Here is my function in process.php
    Code:
    function procNewMessage() {
       global $database, $session, $form;
       /*echo "<script>alert(Got to here);</script>";*/
          if($form->num_errors > 0){
             return false;  //Errors with form
          }
          
          if ($_POST['msgfor']=='Select User') {
          
             $field = "msgfor";  //Use field name for current password
             $form->setError($field, "* Message For not selected");      
             
              $_SESSION['value_array'] = $_POST;
              $_SESSION['error_array'] = $form->getErrorArray();      
          }
          else if ($_POST['newmsg']=='') {
          
             $field = "newmsg";  //Use field name for current password
             $form->setError($field, "* No Message Entered");      
             
              $_SESSION['value_array'] = $_POST;
              $_SESSION['error_array'] = $form->getErrorArray();   
          }
          else {
             /*echo "<script>alert(Got to here 2);</script>";*/
             $q = "INSERT INTO tblMessages (`Message`, `MessageTime`, `MessageDate`, `MessageBy`, `MessageFor`) VALUES ('".$_POST['newmsg']."', '".date('H:i:s')."', '".date('Y-m-d')."', '".$session->username."', '0', '".$_POST['msgfor']."');";
             $retval = $database->query($q);
             /*echo "<script>alert(Got to here 3);</script>";*/
          }
       /*echo "<script>alert(Got to here 4);</script>";*/
       header("Location: ".$session->referrer);
       }

    Any help would be great. I've commented out the alert messages I was using to see how far my code went. If I make an error on purpose, I get the red letter message show up on the form, but if the form is filled in correctly, none of the alert messages popped up. So I commented them out to see if that would make a difference, but it didn't.

    Thank you,

    Brad
    avatar
    Fred-Eric

    Number of posts : 63
    Registration date : 2007-05-13

    Re: Update boolean field to True

    Post  Fred-Eric on Sun Feb 22, 2009 8:02 pm

    Suspect
    I really want to help you further with that but your should post here the form you're using because what I read now makes no sense to me. scratch
    avatar
    mbrad

    Number of posts : 42
    Registration date : 2009-02-19

    Re: Update boolean field to True

    Post  mbrad on Sun Feb 22, 2009 8:18 pm

    Cool.

    Here is the form. Sorry I should have posted it at the start.

    Code:
          <form action="process.php" method="POST">
             <table border="0" cellspacing="0" cellpadding="3" id="NewMessage">
                <tr>
                       <td>Message:</td><td><textarea rows="8" cols="40" id="newmsg" name="newmsg"></textarea></td><td><?php echo $form->error("newmsg"); ?></td>
                        <td>
                           <table>
                                <tr>
                                 <td>For:</td><td><select id="msgfor" name="msgfor">
                                    <?php
                            echo "<option value='Select User'>Select User</option>";
                            while ($row = mysql_fetch_assoc($result)) {
                               foreach($row as $key => $value) {
                                  echo "<option value='".$value."'>".$value."</option>";
                               }
                            }
                                    ?>
                                    </select></td><td><?php echo $form->error("msgfor"); ?></td>
                                </tr>
                                <tr>
                                <td colspan="2" align="right">&nbsp;</td>
                             </tr>
                                <tr>
                                <td colspan="2" align="right">&nbsp;</td>
                             </tr>
                                <tr>
                                <td colspan="2" align="right"><input type="hidden" id="subNewMsg" name="subNewMsg" value="1" /><input type="submit" value="Save" /></td>
                             </tr>
                            </table>
                        </td>
                    </tr>
                </table>
          </form>

    Thanks so much for the quick reply!!

    Brad
    avatar
    Fred-Eric

    Number of posts : 63
    Registration date : 2007-05-13

    Re: Update boolean field to True

    Post  Fred-Eric on Sun Feb 22, 2009 9:34 pm

    try this code

    Code:
    function procNewMessage() {
      global $database, $session, $form;

         
          if ($_POST['msgfor']=='Select User') {
            $field = "msgfor";
            $form->setError($field, "* Message For not selected");     
          }
       
       
        if ($_POST['newmsg']=='') {
            $field = "newmsg";
            $form->setError($field, "* No Message Entered");     
          }
         
         
        if($form->num_errors > 0){
            $_SESSION['value_array'] = $_POST;
            $_SESSION['error_array'] = $form->getErrorArray();
          } else {
            $q = "INSERT INTO tblMessages (`Message`, `MessageTime`, `MessageDate`, `MessageBy`, `MessageFor`) VALUES ('".$_POST['newmsg']."', '".date('H:i:s')."', '".date('Y-m-d')."', '".$session->username."', '0', '".$_POST['msgfor']."');";
            $retval = $database->query($q);
          }
     
     
      header("Location: ".$session->referrer);

      }
    avatar
    Admin
    Admin

    Number of posts : 18
    Registration date : 2007-05-12

    Re: Update boolean field to True

    Post  Admin on Mon Feb 23, 2009 9:19 am

    I also forgot to mention that your form dosn't have hiden field for the process class consctruction redirect the the right function.

    Code:
    <input type="hidden" value="1" name="subNewMessage" />
    and also make sure you add to the constructor the correct redirection to the function

    Code:
    if (isset($_POST['subNewMessage']))
    {
     this->procNewMessage();
    }
    avatar
    mbrad

    Number of posts : 42
    Registration date : 2009-02-19

    Re: Update boolean field to True

    Post  mbrad on Mon Feb 23, 2009 4:08 pm

    Thanks for your replys.

    I do have the
    Code:
    if (isset($_POST['subNewMsg']))
    {
     this->procNewMessage();
    }
    , I just didn't post it... again, sorry.

    I do have that line in my form...
    Code:
    <td colspan="2" align="right"><input type="hidden" id="subNewMsg" name="subNewMsg" value="1" /><input type="submit" value="Save" /></td>

    I tried running your code and got the same result.

    So if I put in incorrect data, I get the error messages show up on my form, but if I put in good data, the page refreshes, the info in the form is gone, but no data is put into the DB into tblMessages.

    Brad
    avatar
    Admin
    Admin

    Number of posts : 18
    Registration date : 2007-05-12

    Re: Update boolean field to True

    Post  Admin on Mon Feb 23, 2009 5:08 pm

    try this code do this:
    Code:

    function procNewMessage() {
      global $database, $session, $form;

         
          if ($_POST['msgfor']=='Select User') {
            $field = "msgfor";
            $form->setError($field, "* Message For not selected");     
          }
       
       
        if ($_POST['newmsg']=='') {
            $field = "newmsg";
            $form->setError($field, "* No Message Entered");     
          }
         
         
        if($form->num_errors > 0){
            $_SESSION['value_array'] = $_POST;
            $_SESSION['error_array'] = $form->getErrorArray();
          } else {
    $q = "INSERT INTO tblMessages (`Message`, `MessageTime`, `MessageDate`, `MessageBy`, `MessageFor`) VALUES (`".$_POST['newmsg']."`, `".date('H:i:s')."`, `".date('Y-m-d')."`, `".$session->username."`, `0`, `".$_POST['msgfor']."`);";
            $retval = $database->query($q);
          }

    if($retval) print '<script>alert("data inserted in db succesffully");</script>';
    else die('try mo modified this request: '.$q);
     
     
      header("Location: ".$session->referrer);

      }


    $q = "INSERT INTO tblMessages (`Message`, `MessageTime`, `MessageDate`, `MessageBy`, `MessageFor`) VALUES (`".$_POST['newmsg']."`, `".date('H:i:s')."`, `".date('Y-m-d')."`, `".$session->username."`, `0`, `".$_POST['msgfor']."`);";
    avatar
    mbrad

    Number of posts : 42
    Registration date : 2009-02-19

    Re: Update boolean field to True

    Post  mbrad on Tue Feb 24, 2009 8:59 am

    I looked at your code to see what was different... I think you changed the apostrophes in the query. Is that correct?

    I changed them in mine with the same result.

    I just can seem to get the data into the database.

    Thanks for all your help I really appreciate it. I'm still trying to figure this out.

    Have a great day,

    Brad
    avatar
    Fred-Eric

    Number of posts : 63
    Registration date : 2007-05-13

    Re: Update boolean field to True

    Post  Fred-Eric on Tue Feb 24, 2009 10:15 am

    Is tblMessages is a constant or it is the name of the table itself?
    avatar
    mbrad

    Number of posts : 42
    Registration date : 2009-02-19

    Re: Update boolean field to True

    Post  mbrad on Tue Feb 24, 2009 9:14 pm

    It's the name of the table it self. Is that bad?

    I used it in my previous function like that
    Code:
    function procReadMessage() {
       global $database, $session;   
       
       $q = 'UPDATE `'.tblMessages.'` SET `MessageRead` = 2 WHERE `tblMessageID` = '.$_POST['rowID'].' LIMIT 1;';
       $retval = $database->query($q);
       
          if($retval) {
          echo "<script>alert ('The item id: ".$_POST['rowID']." has been marked as read.');parent.document.getElementById(\"result".$_POST['rowID']."\").innerHTML = \"This item has been marked as read.\";parent.document.getElementById(\"result".$_POST['rowID']."\").style.display = \"inline\";</script>";
          echo "<script>alert('Made it');</script>";
          header("Location: ".$session->referrer);
          
           
          } else {
          echo "<script>alert ('There was an error updatiing id:".$_POST['rowID']." has not been marked as read.');parent.document.getElementById(\"result".$_POST['rowID']."\").innerHTML = \"There was as an error marking this message as read.\";parent.document.getElementById(\"result".$_POST['rowID']."\").style.display = \"inline\";</script>";
          echo "<script>alert('nope');</script>";
          header("Location: ".$session->referrer);
          }
       }

    This function works.

    Brad
    avatar
    Fred-Eric

    Number of posts : 63
    Registration date : 2007-05-13

    Re: Update boolean field to True

    Post  Fred-Eric on Tue Feb 24, 2009 10:33 pm

    try this

    Code:
       $q = "INSERT INTO `" . tblMessages . "` (`Message`, `MessageTime`, `MessageDate`, `MessageBy`, `MessageFor`) VALUES (`" . addslashes($_POST['newmsg']) . "`, `" . date('H:i:s')."`, `".date('Y-m-d')."`, `" . $session->username . "`, `0`, `" . $_POST['msgfor'] . "`);";

    addslashes to $_POST['newmsg'] before and also change ' to `

    if this is not working maybe the database table settings are not set properly.
    avatar
    Fred-Eric

    Number of posts : 63
    Registration date : 2007-05-13

    Re: Update boolean field to True

    Post  Fred-Eric on Wed Feb 25, 2009 10:15 am

    $q = "INSERT INTO tblMessages (`Message`, `MessageTime`, `MessageDate`, `MessageBy`, `MessageFor`) VALUES (`".$_POST['newmsg']."`, `".date('H:i:s')."`, `".date('Y-m-d')."`, `".$session->username."`, `0`, `".$_POST['msgfor']."`);";

    I think I have found what is the problem, look in red your are trying to INSERT INTO 5 fields but the VALUES contains 6 value of course this will never be updated.


    Code:
    $q = "INSERT INTO `" . tblMessages . "` (`Message`, `MessageTime`, `MessageDate`, `MessageBy`, `MessageFor`) VALUES (`" . addslashes($_POST['newmsg']) . "`, `" . date('H:i:s')."`, `".date('Y-m-d')."`, `" . $session->username . "`, `" . $_POST['msgfor'] . "`);";
    avatar
    Fred-Eric

    Number of posts : 63
    Registration date : 2007-05-13

    Re: Update boolean field to True

    Post  Fred-Eric on Wed Feb 25, 2009 10:24 am

    the best way I think is to create table that will look this

    Code:
    $sql = 'CREATE TABLE `localhost_login`.`tblMessages` (`msgid` INT(13) NOT NULL AUTO_INCREMENT PRIMARY KEY, `msg` LONGTEXT NULL, `timestamp` INT(10) NULL, `msgby` VARCHAR(127) NULL, `msgfor` VARCHAR(127) NULL) ENGINE = MyISAM';

    then update table with that:
    Code:
    $timestamp = time();
    $msg = addslashes($_POST['msg']);
    $msgby = $session->username;
    $msgfor = $_POST['msgfor'];

    $sql = 'INSERT INTO `tblmessages` (`msgid`, `msg`, `timestamp`, `msgby`, `msgfor`) VALUES (NULL, \''.$msg.'\', \''.$timestamp.'\', \''.$msgby.'\', \''.$msgfor.'\');';

    $database->query($q);
    avatar
    mbrad

    Number of posts : 42
    Registration date : 2009-02-19

    Re: Update boolean field to True

    Post  mbrad on Wed Feb 25, 2009 2:29 pm

    Hi Fred-Eric

    I am able to update the database with this function

    Code:
    function procNewMessage() {
            $link = mysql_connect("localhost", "xxxx", "xxxxxx") or die(mysql_error());

          mysql_select_db("TestLogIn") or die(mysql_error());
          
          echo "<script>alert('hi');</script>";
          
          $q = "INSERT INTO `TestLogIn`.`tblMessages` (`tblMessageID`, `Message`, `MessageTime`, `MessageDate`, `MessageBy`, `MessageRead`, `MessageFor`) VALUES (NULL, '".$_POST['newmsg']."', '".date('H:i:s')."', '".date('Y-m-d')."', '".$session->username."', '0', '".$_POST['msgfor']."');";


    echo "<script>alert('hi2');</script>";

          $result = mysql_query($q, $link) or die(mysql_error());
          
          
                
     
     
      header("Location: ".$session->referrer);

      }

    so I'm not sure that my table is incorrect.

    Here is what my table looks like

    Code:
    -- Table structure for table `tblMessages`
    --

    CREATE TABLE IF NOT EXISTS `tblMessages` (
      `tblMessageID` int(11) NOT NULL auto_increment COMMENT 'ID',
      `Message` longtext collate latin1_general_ci NOT NULL COMMENT 'The Message',
      `MessageTime` time NOT NULL COMMENT 'Time of Message',
      `MessageDate` date NOT NULL COMMENT 'Date of Message',
      `MessageBy` text collate latin1_general_ci NOT NULL COMMENT 'Message Taker',
      `MessageRead` tinyint(1) NOT NULL COMMENT 'Message Read?',
      `MessageFor` text collate latin1_general_ci NOT NULL COMMENT 'Spare',
      PRIMARY KEY  (`tblMessageID`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci COMMENT='Messages' AUTO_INCREMENT=13 ;

    I'm going to keep trying to add back the original function to this new function to see if I can get it to work.

    Any other ideas?

    Brad
    avatar
    mbrad

    Number of posts : 42
    Registration date : 2009-02-19

    Re: Update boolean field to True

    Post  mbrad on Wed Feb 25, 2009 2:37 pm

    I can't tell what is different now, but this now works. I used ' instead of ` in the query in the VALUES section. Not sure if that made the difference.

    Code:
    function procNewMessage() {
            global $database, $session, $form;
          
          if ($_POST['msgfor']=='Select User') {
            $field = "msgfor";
            $form->setError($field, "* Message For not selected");   
          }
         if ($_POST['newmsg']=='') {
            $field = "newmsg";
            $form->setError($field, "* No Message Entered");   
          }           
          if($form->num_errors > 0){
            $_SESSION['value_array'] = $_POST;
            $_SESSION['error_array'] = $form->getErrorArray();
          } else {      
          $q = "INSERT INTO `TestLogIn`.`tblMessages` (`tblMessageID`, `Message`, `MessageTime`, `MessageDate`, `MessageBy`, `MessageRead`, `MessageFor`) VALUES (NULL, '".$_POST['newmsg']."', '".date('H:i:s')."', '".date('Y-m-d')."', '".$session->username."', '0', '".$_POST['msgfor']."');";
          $retval = $database->query($q);
          }
         header("Location: ".$session->referrer);
      }

    But it works now, perfectly.

    Thank you, thank you, thank you, thank you for all your help and suggestions, which with out, I would have given up a long time ago. I truly appreciate it.

    Brad cheers
    avatar
    Linchpin311

    Number of posts : 220
    Age : 33
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: Update boolean field to True

    Post  Linchpin311 on Wed Feb 25, 2009 3:03 pm

    that probably was the solution..

    table values should be surrounded with '' (pretty sure a double quote will work too) while almost everything else gets surrounded by `` (are these things accent marks?). If your value is a number, you dont need to put single quotes around it, but its good practice to do so anyway. If you are inserting a NULL (or empty) value into a database you shouldn't be putting quotes or accent marks around it or else MySQL will think you are inserting a string.

    Ive been having some computer problems as of lately, or i woulda gotten to you on this sooner. Good to hear its working now!!


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.

    Sponsored content

    Re: Update boolean field to True

    Post  Sponsored content


      Current date/time is Mon Sep 24, 2018 4:54 pm