Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About CyberShot

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  1. I want to create a database for my person use. I am the treasurer for an HOA. I collect money for 14 units monthly. I currently use a spreadsheet but I figured it would be a great learning experience to try creating a database. ( very little skill ). I want to be able to select a unit and see how much is owed, when the last payment was made and any other notes needed. I can't decide how I should make it. Should I just make a plain database with simple records like a spreadsheet or make it more complicated? by simple, I was thinking one table. ID, name, address ( a four digit number ) , pa
  2. is there a general rule as to when to set a variable? I was watching a tutorial today and the author made a small function that would accept a string. Why would you set the string in the function like that? Would it work if it was just $string? function e($string=""){ do something return $string; }
  3. Ok, I have remade my table to match what you have posted.I had to alter the tables in order to set up the foreign keys. Was that necessary? ALTER TABLE unit ENGINE=InnoDB; ALTER TABLE payment ENGINE=InnoDB; I was then able to set up the relationships. I set the payment_id a the primary_key and the unit_id as the foreign key in the payment table. The unit_id is the unit table should be the primary key set to auto_increment. Is this good?
  4. for the unit table. I set the unit_id as the primary key and auto increment and for the payment set the unit_id as primary key auto increment?
  5. I agree with you 100%. I have managed to create an html select that does display each unit from the database where the value of the select is the address table primary key. This is a home owners association and what I am trying to keep tack of is the HOA dues. Those dues pay the water, sewer, garbage, landscaping and electrical for the complex. There are 14 units. Each unit pays monthly. There is no good cheap software out there that does what I want so I was trying to make something myself but as you can tell, I don't know what I am doing. I made the database, inserted some records and have m
  6. I only need one record per month per unit. each unit could actually make multiple payments per month though. My plan is to output each month into a table and each month the data in that table would reset to zero to show the new payments for each unit for the current month. Then the database would hold all payments made over time. I would like to query the database to show units that have not paid, how much they owe and when the last payment was made and what months are missing. You said it's unusual to join the primary key of one table to another. I guess I don't understand because that i
  7. here are my two tables. you will see in the below in the amount table, there is one record that has a duesID of 5 which does correspond to the address table unitID of 5. This is the correct record to show for unit 4109. I am trying to get a query that will choose the unitID and put the proper record down below so that when I query the database, the correct record will show for the correct unit. Right now, I have a form with unit #, date, amount paid and notes. My thought was that I could put in the unit number and then have the query select the matching number from the unitID in the address ta
  8. Barand. I am trying to get your query working but I am having trouble. It is close though but I am getting an error at the last line. Here is what my database looks like table address unit ( varchar(20) ) unitID ( int, primary key, auto increment ) table amount autodate (timestamp) dues (int(6) ) late (varchar(1) ) paid (varchar(1) ) notes ( varchar(500) ) duesID ( int, primary key, auto increment ) Right now, I am just trying to get a test query in so that I can get a "scaffold" to work off of. so I thought the way this would work is that the query wo
  9. all of this is done on localhost. I would assume it's not as dangerous? I have updated the code to use the if($_SERVER['REQUEST_METHOD'] == 'POST') How do you perform an update that doesn't have variables? are you saying that they are ok to pass if I use prepared statements but not just in an mysqli->query? I do remember reading that PHP_SELF was vulnerable attacks. What should I put there then? I don't want to separate my update function out of the db class. What is the best method for this? why can't you output internal system errors? how do I get my errors if I don'
  10. I created an htlm form using $_SERVER['PHP_SELF'] to update my database and I am calling the form like so <?php if( $_POST['update']){ $unit = $_POST['unit']; $date = $_POST['date']; $amount = $_POST['amount']; $notes = $_POST['notes']; $york->update($unit, $date, $amount, $notes); } ?> in my database class, I have created an update function public function update($unit, $date, $amount, $notes){ $conn = $this->link; $sql = "UPDATE amount SET dues = ' . $amount . ', notes = '. $notes .' WHERE duesID = '. $unit .'"; if (mysqli_query($conn, $sql)) {
  11. this is true that the error does give you the line number but it isn't true that the line it points out is always the problem. It could be 2 or 3 lines above the actual line pointed out. I have seen this before. That said, I do not have any formal programming schooling. I am trying to teach myself which is not as easy as it sounds. There are lots of tutorials out there but they are notorious for leaving out information. They do things but do not tell you why they did them. I just finally came to understand the use of "$this->" as of yesterday.
  12. I see in my post that the braces are messed up. I just didn't copy the code correctly. They are not messed up in the class
  13. I am trying to create a class and I ran into a problem. The connect function is returning a fatal error on the line below and I can't figure out the issue. $result = $this->conn->query("SELECT unit FROM address"); class database { private $server = "localhost"; private $db_user = "my user"; private $db_pass = "my pass"; private $db_name = "my database"; private $conn; private $result = array(); function connect(){ // Create connection $this->conn = new mysqli($this->server, $this->db_user, $this->db_pass, $this->db_name); if ($this
  14. when I first get the information out of WordPress, it looks like this ( this is just a short bit of it ) $theID = get_post_meta(get_the_ID()); $string = $theID['panels_data']; var_dump($string); //gives me the below line string(748) "a:3:{s:7:"widgets";a:1:{i:0;a:3:{s:5:"title";s:4:"home"; When I pass the string to unserialize function, I get an error $string = unserialize($string); echo $string; "warning" unserialize() expects parameter 1 to be string, array given in
  15. That helps a little but my main problem still exists. I get my data and when I dump the variable, it says it's a string that looks like this a:3:{i:1;s:6:"elem 1";i:2;s:6:"elem 2";i:3;s:7:" elem 3" yet when I pass that variable into the unserialize function, I get an error. I thought this is what unserialize was for. it says unserialize() expects parameter 1 to be string, array given in This is why I am confused.
  • 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.