Jump to content

ThePsion5

Members
  • Posts

    203
  • Joined

  • Last visited

Everything posted by ThePsion5

  1. I've been beating myself up trying to install PHP with an Apache server, and no matter what I try nothing seems to work. I'm running Windows XP with Apache version 2.0.55, I've tried installing PHP 4.4.2 and PHP 5.1.2 and so far nothing's worked. I've moved the various DLL files into the system folder, added the "C:\PHP" line to the PATH variable, added all the needed lines of code to the Apache config file, and so far it's either broken Apache or simply not worked. Has anyone else encountered these problems, and if so what did you do to solve them? So far the guides I've found online have been virtually useless.
  2. It appears to be functioning perfectly. Thanks for all the help guys!
  3. Ok, I think I have it figured out. Here are the triggers I plan on using: CREATE TRIGGER Increment_After_Insertion AFTER INSERT ON ClientsToKeywordsFOR EACH ROW BEGINUPDATE Clients SET NumKeywords = NumKeywords+1 WHERE ClientID = NEW.ClientID;UPDATE Keywords SET NumClients = NumClients+1 WHERE keywordID = NEW.KeywordID;END;CREATE TRIGGER Decrement_After_Deletion AFTER DELETE ON ClientsToKeywordsFOR EACH ROW BEGINUPDATE Clients SET NumKeywords = NumKeywords-1 WHERE ClientID = OLD.ClientID;UPDATE Keywords SET NumClients = NumClients-1 WHERE KeywordID = OLD.KeywordID;END;CREATE TRIGGER Modify_After_Update AFTER UPDATE ON ClientsToKeywordsFOR EACH ROW BEGINUPDATE Clients SET NumKeywords = NumKeywords+1 WHERE ClientID = NEW.ClientID;UPDATE Keywords SET NumClients = NumClients+1 WHERE keywordID = NEW.KeywordID;UPDATE Clients SET NumKeywords = NumKeywords-1 WHERE ClientID = OLD.ClientID;UPDATE Keywords SET NumClients = NumClients-1 WHERE KeywordID = OLD.KeywordID;END; The Increment_After_Insertion trigger is activated when a row is inserted into the ClientsToKeywords table and increments the count when it finds a match in the Client table, and does the same for Keywords.The Decrement_After_Deletion trigger is activated when a row is removed from the ClientsToKeywords table and decrements the count when it finds the client who's info was removed.The Modify_After_Update does both since one client gained a keyword and another lost one, and does the same for keywords.Does this make sense? (Unfortunately, I couldn't combine the UPDATE, DELETE, and INSERT values in trigger syntax.)
  4. Is there a simple way to specify for this trigger to execute on UPDATE, INSERT, and DELETE?
  5. Sorry to double-post.I think I may have found an easier solution to implement, although more computationally expensive for the Database. CREATE TRIGGER Recount_Num_Keywords AFTER UPDATE OF ClientID ON ClientstoKeywordsBEGINUPDATE Clients SET NumKeywords (SELECT COUNT(*) FROM ClientsToKeywords WHERE ClientID = new.ClientIDEND I believe that this would work properly...my main question is would this trigger function when values are inserted, deleted, and updated? Or only when values are modified using the UPDATE command?
  6. I'm using MySQL version 5.0.18...and I think I have a partial solution to my problem. If I understand the syntax correctly, this trigger should increment the NumKeywords field if a new entry is added to the ClientsToKeywords table or if a current entry is modified:CREATE TRIGGER Increment_Num_Keywords AFTER UPDATE OF ClientID ON ClientsToKeywordsFOR EACH ROWWHEN new.ClientID = Clients.ClientIDUPDATE Clients SET NumKeywords = NumKeywords + 1 I believe this should take care of incrementing the number of Keywords, but I still don't know how to decrement the old one if a client-keyword mapping is modified.
  7. Hi again,My database consists of 3 tables, two of which contain pure data (Clients, Keywords) and the third (ClientsToKeywords) that is a relationship mapping between the two. I want to record the number of clients per keyword and the number of keywords per client and determined that the most efficient way to do this would be by creating a trigger that updates the value every time the ClientsToKeywords table is modified, but to be honest I'm new to triggers and I'm not sure how to do this. Unfortunately, I havn't been able to find a good online reference for triggers. What would the appropriate syntax be to do this, and where might I be able to find a good trigger tutorial?Database SchemaClients(ClientID, ClientName, ClientWebsite, NumKeywords)Keywords(KeywordID, Keyword, NumClients)ClientsToKeywords(ClientToKeywordID, ClientID, KeywordID, Rating)Note: Underlined fields are primary keys, bold fields are foriegn keys.
  8. Ah, I think I see what the problem is...when I set the auto-increment value to 0 the first value actually inserted into the ClientID in the Clients table was 1, not 0 as I thought. This should clear everything up.Thanks for the help
  9. Here's the exact syntax I used to create the database:CREATE DATABASE ESiteTest3;USE ESiteTest3;CREATE TABLE Clients(ClientID INTEGER NOT NULL AUTO_INCREMENT,SugarID CHAR(36),ClientName CHAR(60) NOT NULL,ClientWebsite CHAR(60) NOT NULL,NumKeywords INTEGER DEFAULT 0,CONSTRAINT Client_PK PRIMARY KEY (ClientID),CONSTRAINT ClientName_Unique UNIQUE (ClientID),CONSTRAINT ClienWeb_Unique UNIQUE (ClientWebsite)) AUTO_INCREMENT = 0;CREATE TABLE Keywords(KeywordID INTEGER NOT NULL AUTO_INCREMENT,Keyword CHAR(60) NOT NULL,NumClients INTEGER DEFAULT 0,CONSTRAINT Keyword_PK PRIMARY KEY (KeywordID),CONSTRAINT Keyword_Unique UNIQUE (KeywordID, Keyword)) AUTO_INCREMENT = 0;CREATE TABLE ClientsToKeywords(ClientToKeywordID INTEGER NOT NULL AUTO_INCREMENT,ClientID INTEGER NOT NULL,KeywordID INTEGER NOT NULL,Rating INTEGER,CONSTRAINT ClientToKeyword_PK PRIMARY KEY (ClientToKeywordID),CONSTRAINT ClientID_FK FOREIGN KEY (ClientID) REFERENCES Clients(ClientID),CONSTRAINT KeywordID_FK FOREIGN KEY (KeywordID) REFERENCES Keywords(KeywordID),CONSTRAINT ClientToKeywordID_Unique UNIQUE (ClientToKeywordID),CONSTRAINT ClientToKeywordRelationship_Unique UNIQUE (ClientID, KeywordID),CONSTRAINT ClientToKeywordRating_Check CHECK (rating >=0 AND rating <= 5)) AUTO_INCREMENT = 0; And I use this code to populate it with test data: INSERT INTO Clients VALUES(0, "", "El Doomo Industries", "www.eldoomo.com", 0);INSERT INTO Clients VALUES(0, "", "Fartknocker Inc.", "www.######.com", 0);INSERT INTO Clients VALUES(0, "", "Alien Empire", "www.aempire.net", 0);INSERT INTO Clients VALUES(0, "", "Redemption!", "www.redemption.com1", 0);INSERT INTO Clients VALUES(0, "", "The Sandwitchery", "www.sandwitchery.com", 0);INSERT INTO Clients VALUES(0, "", "Cornfries for the Heart", "www.ctfh.com", 0);INSERT INTO Clients VALUES(0, "", "Happytimes Personal Counseling", "www.happytimes.org", 0);INSERT INTO Clients VALUES(0, "", "Alliance Software", "www.alliance.com", 0);INSERT INTO Clients VALUES(0, "", "Ninja Inc.", "www.ninja.com", 0);INSERT INTO Keywords VALUES(0, "Doom", 0);INSERT INTO Keywords VALUES(0, "Unpleasant", 0);INSERT INTO Keywords VALUES(0, "Evil", 0);INSERT INTO Keywords VALUES(0, "Foriegners", 0);INSERT INTO Keywords VALUES(0, "Silence", 0);INSERT INTO Keywords VALUES(0, "Video Games", 0);INSERT INTO Keywords VALUES(0, "Food", 0);INSERT INTO Keywords VALUES(0, "Happiness", 0);INSERT INTO Keywords VALUES(0, "Coolness", 0);INSERT INTO ClientsToKeywords VALUES(0, 0, 0, 4);INSERT INTO ClientsToKeywords VALUES(0, 1, 0, 4);INSERT INTO ClientsToKeywords VALUES(0, 3, 0, 4);INSERT INTO ClientsToKeywords VALUES(0, 5, 0, 4);INSERT INTO ClientsToKeywords VALUES(0, 8, 0, 4);INSERT INTO ClientsToKeywords VALUES(0, 3, 1, 4);INSERT INTO ClientsToKeywords VALUES(0, 5, 1, 4);INSERT INTO ClientsToKeywords VALUES(0, 2, 1, 4);INSERT INTO ClientsToKeywords VALUES(0, 1, 1, 4);INSERT INTO ClientsToKeywords VALUES(0, 0, 2, 4);INSERT INTO ClientsToKeywords VALUES(0, 2, 2, 4);INSERT INTO ClientsToKeywords VALUES(0, 5, 2, 4);INSERT INTO ClientsToKeywords VALUES(0, 2, 3, 4);INSERT INTO ClientsToKeywords VALUES(0, 8, 3, 4);INSERT INTO ClientsToKeywords VALUES(0, 5, 4, 4);INSERT INTO ClientsToKeywords VALUES(0, 6, 4, 4);INSERT INTO ClientsToKeywords VALUES(0, 8, 4, 4);INSERT INTO ClientsToKeywords VALUES(0, 0, 5, 4);INSERT INTO ClientsToKeywords VALUES(0, 7, 5, 4);INSERT INTO ClientsToKeywords VALUES(0, 8, 5, 4);INSERT INTO ClientsToKeywords VALUES(0, 4, 6, 4);INSERT INTO ClientsToKeywords VALUES(0, 5, 6, 4);INSERT INTO ClientsToKeywords VALUES(0, 3, 7, 4);INSERT INTO ClientsToKeywords VALUES(0, 7, 7, 4);INSERT INTO ClientsToKeywords VALUES(0, 7, 8, 4);INSERT INTO ClientsToKeywords VALUES(0, 8, 8, 4); I hope this helps!
  10. The ClientID is set to auto-increment if a value of 0 or null is entered, and previous to that I had inserted values into both the Client and Keyword tables, so I don't see how this is a problem...Would it help if I told you that I was using MySQL version 5.0.16?
  11. ThePsion5

    Another Problem

    Hi again. I created a table in MySQL using the following statements: CREATE TABLE ClientsToKeywords(ClientToKeywordID INTEGER NOT NULL AUTO_INCREMENT,ClientID INTEGER NOT NULL,KeywordID INTEGER NOT NULL,Rating INTEGER,CONSTRAINT PRIMARY KEY (ClientToKeywordID),CONSTRAINT FOREIGN KEY (ClientID) REFERENCES Clients(ClientID),CONSTRAINT FOREIGN KEY (KeywordID) REFERENES Keywords (KeywordID),CONSTRAINT UNIQUE (ClientID, KeywordID),) AUTO_INCREMENT = 0; During the process of populating the database with some test data, i try and enter any one of these statement: INSERT INTO ClientsToKeywords VALUES(0, 0, 2, 4);INSERT INTO ClientsToKeywords VALUES(0, 0, 5, 4);INSERT INTO ClientsToKeywords VALUES(0, 0, 0, 4); And recieve this error: ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails ('test3/clientstokeywords', CONSTRAINT FOREIGN KEY ('ClientID') REFERENCES 'clients' ('ClientID')) Unfortunately, I'm new to databases, and I don't understand why this would happen. Any help?
  12. ThePsion5

    SQL Reader?

    Hi,I'm writing many statements in SQL in a notepad file, but after awhile it can get hard to distinguish SQL statements from table names, despite using caps and formatting my statements. Are there any utilities out there that will do something along the lines of color-coding SQL syntax, like Dreamweaver does HTML?Thanks in advance.
  13. I know the standard solution for this problem is to add the path to my PHP directory into Computer->Properties->Advanced->Environment Variables->System Variables, but I've tried that - no effect. I still recieve the same error message.Moving the listed file into my Windows/ or Windows/System32 has no effect, and moving the file into my Apache2 directory gives me another error:"Unable to load dynamic library '.php_mysql.dll' - the specified procedure could not be found."Any ideas? I'm currently running Apache 2.0.55 with PHP 5.1.1 and MySQL 5.0.16
  14. Hi,I am in the process of creating a tabbed web page using javaScript and PHP. The basic idea is to display one of three menus from which the user can pick various items to be displayed on another section of the page. In addition, the page must remember what tab the user last chose and display it the next time the web page has been visited. Optionally, this page can remember the last menu item the user visited as well, and this option can be turned on or off at the bottom of the page.However, I am running into a bit of a problem. My code is set up that a cookie (consisting of the ID of the last tag chosen, the last menu item chosen, and a setting to remember the menu item or not) is modified at the following times:1. When a tab is clicked2. When a menu item is chosen (the page reloads since PHP code handles the display of actual content)3. The "remember menu item" is modifiedThe problem with this approach is that my PHP code retrieves values from the cookie, and displays a default item if the "remember menu item" option is turned off. But since the page refreshes every time a menu item is chosen, this creates a problem. Since the PHP pulls code directly from a cookie, if the "remember menu item" option is turned off it will always display the default page no matter what the user clicks. PHP won't let me modify the cookie values outside of the header, either. Any suggestions (I can post code if that would help). Thanks in advance!
  15. Actually, I found out what the problem is.In my HTML file, I was using placeholders for images that referenced a non-existant file. When firefox tries to read these images, it apparently doesn't give up 2/3 times and although it loads the rest of the HTML, it never gets around to executing the javascript. I appreciate the attention though. Thanks!
  16. Nevermind, I figured out what the problem is. I used placeholders for images in my HTML, and since the source file for those images didn't exist, firefox stopped reloading the page for some reason when i tried to refresh. Taking out the href for the non-existant images solved the problem.Moderators, if you would please lock this topic. Thanks!
  17. Hi,Firefox is doing something quite perplexing - about two out of every three times I reload an HTML file I've created it, it acts as if I'm continually trying to load it (displaying the load icon on the tab) and doesn't refresh properly, which breaks some javascript i've included in the page. I thought at first it was the javascript, but i continued to encounter errors even when all of it was removed from the HTML file. Has anyone else encountered this problem?
  18. Well, I've done some tests and found that it only happens on my page, which means some part of my javaScript is preventing the page from reloading properly. I have no idea what, however.Is someone willing to take a look at my entire javascript code? It's not that long, but I'd feel like an arse posting the entire thing on here and making people read through it.
  19. Hi,I'm creating a piece of javascript code designed to implement a simple tabbed web interface that uses a basic cookie to record the last tab visited. I'm familiar with programming languages in general, but I'm new to javascript and i've been encountering a perplexing error that seems to only occur with Firefox.Initially loading the page works well in IE and Firefox, but for some reason the code breaks upon some (but not all) subsequent loads in firefox. As far as I can tell, it has something to do with the onLoad function, specifically, it seems like Firefox does not call the onLoad function every time the refresh button is pressed, or only calls at certain intervals (like when i hit the refresh button 5 seconds after the last time i hit it. Is there something i'm missing? Thanks!-SeanEdit: The alert boxes are for debugging purposes.Here's my JavaScript code: function checkCookie(){ //Retrieve the cookie tabCookie = getCookie('tabCookie') //If it exists if (tabCookie!=null) { //Execute the display tabs function with the cookie's information displayTabs(tabCookie) } else { //Otherwise, make the cookie setCookie('tabCookie',tabCookie) displayTabs("immenu") }} function displayTabs(activeTab){ var tabArray = new Array("immenu","semmenu","seamenu"); var thisTab for (i = 0;i < tabArray.length; i++) { //Iterate through the tab array thisTab = document.getElementById(tabArray[i]) //Set each tab to not display alert(document.getElementById(tabArray[i]) + " should equal " + thisTab); thisTab.style.display = "none"; } if(activeTab == null) { //If the active tab is null, display a default document.getElementById("immenu").style.display = "inline"; } else { //Otherwise, display the appropriate tag document.getElementById(activeTab).style.display = "inline"; }} And Here's the relevant HTML: <script src="../JavaScripts/tabCookie.js"></script></HEAD><BODY onload="checkCookie();">
×
×
  • Create New...