Jump to content

chiprivers

Members
  • Posts

    468
  • Joined

  • Last visited

    Never

About chiprivers

  • Birthday 03/19/1979

Contact Methods

  • MSN
    dan@cullmail.co.uk

Profile Information

  • Gender
    Male
  • Location
    UK

chiprivers's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. Sorted I was using private instead of protected on my properties. I said I was new
  2. I am tackling my first major PHP application using OOP and I am getting a little stuck with extending classes. I want to be able to create a parent class which contains a number of properties and methods, and be able to extend this class with the ability to access the parent properties and methods. The specific problem I am having at the moment is with a property holding a MySQL connection. ie. class DatabaseManager { private $mysqli; public function DatabaseManager() { $this->mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE); } // various generic database methods declared here } class AnotherClass extends DatabaseManager { public function AnotherClass() { $this->DatabaseManager(); } public function methodUsingMysqli($query) { $result = $this->mysqli->prepare($query); // do something with result blah blah } } When I try an run my application using the above construct and trying to access the $mysqli property declared in the parent class, it says that it does not exist.
  3. How do I create alternative contractor methods for my class. Like when you create a DateTime object you can create it using an alternative time passed by a string using DateTime::createFromFormat(). I want to have a default constructor method but a couple of extra contractor methods that can be called when the instance is created.
  4. It does have permission - it works when using mysql_connect()
  5. I have just set up MAMP on my new MacBook Pro and I am having trouble getting my MySQL connection working. When I use the following code: $mysqli = new mysqli('localhost', 'application', 'application', 'dorset'); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (".$mysqli-errno.") ".$mysqli->connect_error; } I get this error: Failed to connect to MySQL: () Access denied for user 'application'@'localhost' (using password: YES) However if I use the old mysql_connect() function, it doesnt throw back any errors?! Any ideas?
  6. I am writing a function to update an existing record and I want to be able to return the values from the updated record prior to the update. ie. A record in table 'employee' has values id = 1, first_name = 'Joe' and last_name = 'Bloggs' The function is passed employee id 1 and new name Tom Cobley so the function will update record 1 with the respective name entries. Easy enough! However, I want the function to be able to return the old name, Joe Bloggs. Can this be done with a single query which updates the record with the specified values but also returns the old values at the same time or do I have to first query for the values of record 1 and then run a second update query?
  7. I'm not actually using PHP and MySQL for this query, I am using MS Access which is querying an Oracle database. I have posted here as I usually work with PHP and MySQL and as I understand it SQL is pretty much SQL which ever application I am using. I think the problem with the query is due to Access not liking the comparison between INT and VARCHAR so although it would probably normally work in SQL I need to try and work around the MS Access issue.
  8. I am struggling with a table join where the comparitive table fields are in different formats; one int and one var. I know that this is sloppy database construction but unfortunately it is not my database and I do not have any control over the table construction. In my query I have a join as below: SELECT ... ... FROM tableA LEFT JOIN tableB ON tableA.varField = tableB.intField Unfortunately this is not running because the datatypes in the fields that I am joining on are not the same datatype. Is there a function I can use to change the var value to an int before comparing it, or vice versa? I think from googling that I should be using cast() or convert() but I cannot find a clear explanation of these functions that has enabled me to workout if and how I could use either of these functions. Any help would be very much appreciated.
  9. thank you - that looks like it will work - will give it a go
  10. That looks good but do I also need to specify the year also to ensure that it only returns entries with a matching month in the current year and not say all records with a review date in October every year?
  11. Please could somebody help me with this, I assume, pretty simple SQL where clause... I have a DATE column in my table (field is called reviewdate) and I would like to return all records where the value in this column is within the current month. Could somebody help with the WHERE clause? Something like... WHERE functionformonthandyearof(reviewdate) = functionforcurrentmonthandyear() Many thanks in advance.
  12. Thanks. All sorted now. I did resolve the issue but had not worked out why it wasn't working originally. Simple now you point it out!!
  13. I am trying to create a loop that will work through the dates of the current month; I have the following piece of code for the loop: $monthFloor = DateTime::createFromFormat('j H:i:s', '1 0:0:0'); $monthCeiling = DateTime::createFromFormat('j H:i:s', $monthFloor->format('t').' 0:0:0'); for ( $monthDate = DateTime::createFromFormat('Y-m-d H:i:s', $monthFloor->format('Y-m-d H:i:s')); $monthDate->format('d') <= $monthCeiling->format('d'); $monthDate->modify('+ 1 day') ) { echo $monthDate->format('Y-m-d H:i:s')."<br />"; } But when I run this, it loops through the dates of the current month twice!? why is it doing this? and how can I rectify the loop so it only goes through the month once?
  14. I am not sure of what aspect of programming is best used for achieving my objective so I will start by posting this question here. Mods, please feel free to reposition this thread if you feel appropriate. I want to produce an interactive map upon which there will be a number of elements that can be repositioned on the map, and depending on the positions where they are put, various aspects of the map will change. I intend to have a <div> that contains this whole map which will have a background image which will display the map outline. I will use several smaller <div>s as interative elements on the map which will moveable. I will use jquery's draggable feature to enable this. So far so good. The bit I am unsure on how to do is how to produce some irregular shaped polygon sectors on the map which I can manipulate. What I need to do is divide the map up in to a number of sectors. I then need to be able to control the appearance of these sectors using CSS as if they were an element. For example, if one of the draggable elements is repositioned within one of these sectors, I need to be able to run a function in jquery that will change the background colour of the sector. Is there a way of creating an irregular shaped div? Please let me know if I need to explain this further.
  15. In my current application, I am working with dates in the format 'YYYY-MM-DD HH:MM:SS'. The main reason I am using this format is because it is the format stored in my MYSQL database. I have had no problems working with this format in the PHP elements of my script, however I need some assistance with the javascript! I need to be able to output a datetime string in the above format from my javascript date object. In PHP it woudld be simple, $date->format('Y-m-d H:i:s'); but from what I can see with Javascript, you have to extract each portion of the date and time. This wouldn't be such a problem if the numbers for months and days were prefixed with 0s where applicable! Is there a straight forward function for this that I have missed somewhere?
×
×
  • 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.