Jump to content

NomadicJosh

Members
  • Posts

    190
  • Joined

  • Last visited

About NomadicJosh

  • Birthday 06/25/1977

Contact Methods

  • Website URL
    https://codefyphp.com/

Profile Information

  • Gender
    Male
  • Location
    Colorado Springs
  • Age
    46

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

NomadicJosh's Achievements

Member

Member (2/5)

18

Reputation

  1. @richb201 Can you maybe share with us some code that we can look at?
  2. Just like I said, you are missing the ending quotation at the end of the where clause. It should look something like this: <?php $editquery = mysql_query("UPDATE users SET email=$email, password=$password, location=$location, picture=$picture, website=$website, about=$about WHERE user_id='" ._$SESSION['user'] . "'"); ?>
  3. Yes, that is the correct syntax, but in your example, you're missing the closing quotation, so you have to be careful of that.
  4. I think what you need is mysqli_stmt_fetch, and you should also take a look at mysqli_prepare. Those two resources should help steer you into the right direction.
  5. You are using INSERT syntax instead of UPDATE syntax. Your UPDATE query should follow this syntax: UPDATE table_name SET field1=new-value1, field2=new-value2 WHERE field = value;
  6. Sorry, what I should have wrote was this instead: error_log(var_export(mysqli_query( $this->_conn, $query ),true)); If that still does not populate error messages on your server, then if you are using Firefox or Chrome, use the network monitor when submitting the form to make sure the fields being posted match the database fields or see if there is some other problem.
  7. Can you also post the code that is doing the admin check?
  8. I am reposting your code in a much more readable format: public function selectAction($action,$id){ switch($action){ case ('novisibol') : $visibol= 1; if( !$res=$this->_modelAdmin->visibleMenu($visibol,$id)){ echo 'errore nel cambio dello stato'; }else { header ('Location: admin.php?menu'); } break ; case ('visibol') : $visibol= 0 ; if( !$res=$this->_modelAdmin->visibleMenu($visibol,$id)){ echo 'errore nel cambio dello stato'; }else { header ('Location: admin.php?menu'); } public function visibleMenu($id,$visibol){ if( empty($id) ) return false ; if ($visibol > 1) return false ; if ($visibol==0){ $this->_db->update( 'menu',array('menu_visibol'=>1),'menu_id='.$id ); }else { $this->_db->update( 'menu',array('menu_visibol'=>0),'menu_id='. $id ); } return true ; } public function update( $table, $values, $conditions = '1' ){ $first = true; $query = "UPDATE " . $table; $query .= " SET "; foreach( $values as $name => $value ){ if( ! $first ){ $query .= ", "; } $query .= $name . " = " . $value; $first = false; } $query .= " WHERE "; $query .= $conditions; return mysqli_query( $this->_conn, $query ); } In what you call your 3rd class, it seems a bit off, but I am not sure. Before return mysqli_query( $this->_conn, $query ); add this before it: error_log(var_export($query,true)); When the query runs, it will post it to your error log and then you will be able to see if your query is actually doing what you want it to do.
  9. Figured it out. I was missing the data source: success: function(data) {}
  10. I have a dropdown list of departments being pulled from the database. On the same page, you can click a button, a modal form appears and you can add another department if the department you want doesn't exist. After the form is submitted, I need the new value appended to the dropdown list for use. I am not fluent in jquery and ajax at all, so I need help figuring out what is wrong with my code. Below I am pasting each element separately along with the json output as well as the error message. Javascript: <script type="text/javascript"> $(function() { $("#btn_dept").click(function(e) { e.preventDefault(); var deptCode = $("#newDeptCode").val(); var deptTypeCode = $("#deptType").val(); var deptName = $("#deptName").val(); var deptEmail = $("#deptEmail").val(); var deptPhone = $("#deptPhone").val(); var deptDesc = $("#deptDesc").val(); var dataString = 'deptCode='+deptCode+'&deptTypeCode='+deptTypeCode+'&deptName='+deptName+ '&deptEmail='+deptEmail+'&deptPhone='+deptPhone+'&deptDesc='+deptDesc; if(deptCode == '') { $('.success').fadeOut(200).hide(); $('.error').fadeIn(200).show(); } if(deptTypeCode == '') { $('.success').fadeOut(200).hide(); $('.error').fadeIn(200).show(); } if(deptName == '') { $('.success').fadeOut(200).hide(); $('.error').fadeIn(200).show(); } else { $.ajax({ type: "POST", url: "<?=url('/crse/dept/');?>", data: dataString, success: function() { $('#form').fadeOut(200).hide(); $('.success').fadeIn(200).show(); $('.error').fadeOut(200).hide(); $("#deptForm")[0].reset(); $('#deptCode').append($('<option>', { value: data.deptCode, text: deptCode+' '+deptName })); } }); } return false; }); }); </script> Modal Form: <div class="modal fade" id="dept"> <form class="form-horizontal margin-none" id="deptForm" autocomplete="off"> <div class="dialog-form modal-dialog"> <div class="modal-content"> <!-- Modal heading --> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3 class="modal-title"><?=_t( 'Department' );?></h3> </div> <!-- // Modal heading END --> <div class="modal-body"> <div class="error"><?=_t( 'You must fill out the required fields.' );?></div> <div class="success"><?=_t( 'The Department was created successfully.' );?></div> <!-- Group --> <div class="form-group"> <label class="col-md-3 control-label"><font color="red">*</font> <?=_t( 'Department Code' );?></label> <div class="col-md-8"> <input class="form-control" id="newDeptCode" type="text" name="deptCode" required/> </div> </div> <!-- // Group END --> <!-- Group --> <div class="form-group"> <label class="col-md-3 control-label"><font color="red">*</font> <?=_t( 'Department Type' );?></label> <div class="col-md-8"> <?=dept_type_select();?> </div> </div> <!-- // Group END --> <!-- Group --> <div class="form-group"> <label class="col-md-3 control-label"><font color="red">*</font> <?=_t( 'Department Name' );?></label> <div class="col-md-8"> <input class="form-control" id="deptName" type="text" name="deptName" required/> </div> </div> <!-- // Group END --> <!-- Group --> <div class="form-group"> <label class="col-md-3 control-label"><?=_t( 'Department Email' );?></label> <div class="col-md-8"> <input class="form-control" id="deptEmail" type="text" name="deptEmail" /> </div> </div> <!-- // Group END --> <!-- Group --> <div class="form-group"> <label class="col-md-3 control-label"><?=_t( 'Department Phone' );?></label> <div class="col-md-8"> <input class="form-control" id="deptPhone" type="text" name="deptPhone" /> </div> </div> <!-- // Group END --> <!-- Group --> <div class="form-group"> <label class="col-md-3 control-label"><?=_t( 'Short Description' );?></label> <div class="col-md-8"> <input class="form-control" id="deptDesc" type="text" name="deptDesc" /> </div> </div> <!-- // Group END --> </div> <div class="modal-footer"> <button type="submit" id="btn_dept" class="btn btn-icon btn-default"><i></i><?=_t( 'Add' );?></button> <button type="button" data-dismiss="modal" class="btn btn-icon btn-primary"><i></i><?=_t( 'Cancel' );?></button> </div> </div> </div> </form> </div> Dropdown list of departments: <div class="form-group"> <label class="col-md-3 control-label"><font color="red">*</font> <?=_t( 'Department' );?></label> <div class="col-md-8"> <select name="deptCode" id="deptCode" class="selectpicker form-control" data-style="btn-info" data-size="10" data-live-search="true" required> <option value=""> </option> <?php table_dropdown('department', 'deptTypeCode = "acad" AND deptCode <> "NULL"', 'deptCode', 'deptCode', 'deptName'); ?> </select> </div> <a<?=ae('access_forms');?> href="#dept" data-toggle="modal" title="Department" class="btn btn-primary"><i class="fa fa-plus"></i></a> </div> Database Query: $dept = $app->db->department(); foreach($_POST as $k => $v) { $dept->$k = $v; } $dept->save(); $ID = $dept->lastInsertId(); $department = $app->db->department() ->where('deptID = ?', $ID); $q = $department->find(function($data) { $array = []; foreach ($data as $d) { $array[] = $d; } return $array; }); echo json_encode($q); JSON output: {"deptID":"40","deptTypeCode":"ACAD","deptCode":"HIST","deptName":"History","deptEmail":"","deptPhone":"","deptDesc":"","LastUpdate":"2015-07-30 09:33:00"} Error message output in Chrome: Uncaught ReferenceError: data is not defined Any help with figuring this out is greatly appreciated.
  11. Check out this stackoverflow post and see if this may help you with your issue: http://stackoverflow.com/questions/4151743/how-i-change-the-thickness-of-my-hr-tag
  12. If you are wanting to learn more about mysqli and hone in on your skills, you can check out the documentation on php.net: http://php.net/manual/en/book.mysqli.php However, if you are looking to convert your current code from mysql functions to mysqli in a hurry, there was a converter tool on Oracle's website that I believe has been relocated to Github: https://github.com/philip/MySQLConverterTool
  13. In your initial query, you had WHERE id='$tid', but then in the second query when you fixed where clause, you have topic.id=$tid. So first, which one is it? If it is the second one, shouldn't it be topics.id=$tid, with an (s)?
  14. Don't know if there are others here who are familiar with OpenSIS or have used it. Have you tried posting this request over at OpenSIS's forums, if they have one?
  15. I think you are not seeing the results you need because you are setting the sessions on the landing page instead of in the class. I think your login method should look similar to what's below: public function login($username,$password){ //must start a session session_start(); $hashed = $this->get_user_hash($username); if($this->password_verify($password,$hashed) == 1){ /** memberID and firstname variables must be pulled from the database on successful login in order for the sessions to be set. Similar to how you are querying the database for those data elements in your get_user_hash method. */ $_SESSION['loggedin'] = true; $_SESSION['memberID'] = $memberID['memberID']; $_SESSION['firstname'] = $firstname['firstname']; return true; } } The above code will still not give you the results you need, but the comment I've added about the database will help point you into the right direction.
×
×
  • 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.