Jump to content

sudsy1970

Members
  • Posts

    91
  • Joined

  • Last visited

    Never

Everything posted by sudsy1970

  1. ok have struggled on a bit more and now i have the error message This is pointing to the colon, i have tried adding a " afterwards as i thought it may view it as a special charaacter but end up with the same error. Can one explain it to me please ?
  2. very similiar to search i think static $get_message = "SELECT id,title,message FROM messages WHERE id = ?" ; function getOneMessage($id) { $values = array($id); $stmt = $this->doStatement(self::$get_message, $values); $result = $stmt->fetchAll(); return $result; }
  3. that is because when the message amend is selected the id is passed via php so the table knows which entry to get. I will check on whether i have entered the code correctly, not at pc at present. Can i just check i have a folder called assignment with all my files for the blog, if i just create the triggers i need and save them in the same folder, will they automatically 'trigger' or do i need to call them, if so how ?
  4. Because of : Advanced Web Technologies Assessment 1 – Website marking sheet Student name and number: Marker: Mark and comments Basic functionalities - Articles can be added and viewed 1 point - Articles can be amended and deleted 1 point - You can search for articles 1 point (3 points) OO Programming and Patterns - You have used OO programming techniques (inheritance, static methods, abstract classes etc.) when appropriate. 1 point - Your website is based on a suitable Architectural Pattern (1 point for the example featured on the Wiki) 3 points (4 points) Versioning - A history of versions is kept 1 point - Versions can be compared 1 point - Articles can be rolled back to older versions 1 point (3 points)RSS - The website is consuming (parsing and appropriately displaying) an existing feed. 1 point - The website is dynamically producing its own compliant web feed. 1 point (2 points) API - The website makes use of an API to offer useful functionality (e.g. search, spelling, social networking, ecommerce, etc.)) Note: Reusing the examples from the Wiki will NOT grant you any points! 1 point for simple use (e.g. widget) 2 points for complex REST/SOAP request (2 points) Ajax - The user experience is improved by appropriate use of Ajax technology (live search, form filling assistance…) 1 point per Ajax feature, up to a max. of 2 points (2 points) Total ________ out of 16
  5. Ok so i have tried again, basically what needs to happen is Select * from messages where ID = ? THEN Insert into messages_audit (info from above THEN delete from messages where ID = ? Have tried to create a trigger to make this happen which goes like: mysql> Delimiter // mysql> CREATE TRIGGER messages_bd -> BEFORE DELETE ON messages ->FOR EACH ROW ->BEGIN ->INSERT INTO messages_audit (id,title,message,date_added) VALUES (SELECT * FROMmessages WHERE ID = ?); ->END// A) does this seem to be ok B) i get the error code Anyone got any ideas please ?
  6. sorry should have said, I have already tried that and still get the same error message. When i posted the the code i hadn't realised i had moved the <? tag when fiddling. have also been playing with my link tag when i think should read : $feed.="<link>localhost/bloggy/index.php</link>"; does this look right for the file on a web server ?
  7. Anyone any ideas on why the sql could be causing this error ?
  8. I did look up triggers and found it very confusing which is why i asked for help in the first place. Perhaps the scorn passed from you is not worth the extra mark i could receive !
  9. ahh hah, right thanks for that, found it and navigated to it to find XML Parsing Error: not well-formed Location: http://127.0.0.1/bloggy/rss.xml Line Number 15, Column 3: $sql = "SELECT title FROM messages ORDER BY date_added DESC limit 0,10"; --^
  10. as the feed does not work, will there be an output and if so how do i see it ?
  11. Hi i have a simple blog which is stored in a table called messages, i have tried to create an rss feed that poeple can link to but am a bit stuck. the feed does not validate with the error code of: Sorry This feed does not validate. line 15, column 2: XML parsing error: <unknown>:15:2: not well-formed (invalid token) [help] $sql = "SELECT title FROM messages ORDER BY date_added DESC limit 0,10"; Anybody got any ideas on this please, have read the rss pages and can comsume a fedd ok just cant produce one. <?php $host = ""; $user = ""; $pass = ""; $port = "3306"; $database = "uni"; $MySQL = mysql_connect( "$host:$port", $user, $pass ); mysql_select_db( $database, $MySQL) or die ( "Couldn't open $database: ".mysql_error() ); ?> // Get latest items from db $sql = "SELECT title FROM messages ORDER BY date_added DESC limit 0,10"; $rst = mysql_query($sql); // Loop through data and build feed items $items = ""; while($a_row = mysql_fetch_assoc($rst)) { $items.= "<item>"; $items.= " <title>{$rst['title']}</title>"; $items.= " <link>{$rst['link']}</link>"; $items.= " <description>{$rst['description']}</description>"; $items.= "</item>"; } // Build feed text $feed = "<?xml version=\"1.0\"?>"; $feed.= "<rss version=\"2.0\">"; $feed.= " <channel>"; $feed.= " <title>My cool feed</title>"; $feed.= " <link>http://mi-linux.wlv.ac.uk/~0274148/AWT/blog/index.php</link>"; $feed.= " <description>A cool feed</description>"; $feed.= " $items"; $feed.= " </channel>"; $feed.= "</rss>"; // Display feed text echo $feed;
  12. Well it didn't work anyway and this is only to show it can be done for a project, if i can get it working it could provide extra points. i have a php function that calls the sql code so might just see if i can add to that to back up the record i am deleting.
  13. ok have had a go and have got the following does that look right ? [code ]CREATE TRIGGER CreatePostRevision BEFORE UPDATE ON messages FOR EACH ROW BEGIN INSERT INTO messages_audit (title,message,date_added) values(?,?,?) VALUES (OLD.<title>,OLD.<message>,OLD.<date_added>) END; Now can i just write another trigger for a delete ? where does the code sit, do i just make a sql folder and leave it in there as i am thinking that this will always trigger whenever the update/delete is executed ? Thanks for your patience
  14. have tried for ages and i am stuck. The code to enter in the info into my blog table is: INSERT INTO messages(title,message,date_added) values(?,?,?) if i ever get the amend to work it will find it via $id SELECT id,title,message FROM messages WHERE id = ? so if i select the message , insert it to a backup table and also update the original table will i get : SELECT id,title,message FROM messages WHERE id = ? INSERT INTO messages_audit(title,message,date_added) values(?,?,?) AND UPDATE messages(title,message,date_added) values(?,?,?) If this is right can i use a simialr approach for delete and add ?
  15. Thanks for the reply, i have a very simple table, with an id number, title, message and date added entries, so i am guessing that just getting another table called versions would be a n easier option. i shall attempt that as i only really need to demo that it can be done, will post the code when i get stuck lol
  16. Can php be used to get two blog entries and compare them side by side, with a choice one which one to use. A bit like wikipedia has ?
  17. Thanks for the info, i have been told that an easy way to do this would be to use a transaction or stored procedure: a) is this true b) how would this look (roughly) C) Can i just save the code as a .sql file as technically it doesn't interact with my code, only when some happens to the database ?
  18. Hi all, just a quick query, i have created a very simple blog, where messages can be added, amended or deleted and are stored in a DB called messages. i now have to implement versioning where a history is kept, versions can be compared and also rolled back to earlier versions. Just wanted some info or ideas on how to do it really, i am guessing that i would have another DB that gets updated when the original DB does, does that sound right ? cheers for any info sudsy
  19. ok i can't see it it but here is what i am thinking should happen: the id of the selected blog gets sent to the function amendMessage, it puts it in an array called $values then calls the SQL statement below to find the entry in the db, which is returned to populate the form and should be displayed on the screen. Is that right ? static $amend_message = "SELECT * FROM messages WHERE id = ?";[code=php:0] function amendMessage($id) { $values = array($id); $stmt = $this->doStatement(self::$amend_message, $values); } [/code] function doExecute(Request $request) { $search = $request->getProperty('search'); // Create manager object $manager = new ManagerMessage(); $data = $manager->amendMessage($search); // Include view include("views/add_form.php");
  20. Hi guys, Am having trouble with my OO php blog. i can add, delete and search for messages but cannot update them as i get the folowing eror message (see below) Have checked that when i hover over the link i do get an id number and it is pointing to the correct cmd i.e. blogAmend. Any ideas as to where i am going wrong, files attatched for further info. [attachment deleted by admin]
  21. Hi all, I am trying to implement a search of a blog, using Object Oriented PHP, a concept which seems a little alien to me. I have had an attempt at it but it doesn't seem to work, but am not really sure why. I think that i have told the search on post to refer to the command BlogSearch and then within that command look for the titles of the blogs that are the same as the search and display them. Any help greatly appreciated. <?php /*views/index.php*/ require_once("ViewHelper.php"); ViewHelper::DisplayHeader("Blog index");?> <h1>Blog index</h1> <p>You can <a href="index.php?cmd=BlogAddForm">add messages</a> !</p> <form action="index.php?cmd=BlogSearch" method="post"> Search: <input name="search"> <input type="submit" value="Search!"> </form> <? foreach($data as $message) echo("<div class=\"message\"> <h2>{$message['title']}</h2> <p>{$message['message']}</p> <a href=\"index.php?cmd=BlogDelete&id={$message['id']}\">Delete this message</a> </div>"); ?> <?ViewHelper::DisplayFooter();?> <?php require_once("ViewHelper.php"); ViewHelper::DisplayHeader("Blog index");?> <? foreach($title as $search) echo("<div class=\"message\"> <h2>{$message['title']}</h2> <p>{$message['message']}</p> </div>"); ?> <?ViewHelper::DisplayFooter();?> ?>
  22. Thanks i will give that a go, seems very complicated as an introduction. And yes this is the way we are being taught.
  23. Cheers for that, this was just the way we were required to code it. so i am guessing that the yes/no buttons will be generated in the views/index.php and the result POST'd back?
  24. Hi all, have constructed a blog through some tutorials which will add and delete messages. I wish to add some form of confirmation box with a yes/no button before deleting but am not sure where to begin. Thanks for any help <?php // Command_BlogDelete.php //############################################################################ // SearchVenueCommand class //############################################################################ class Command_BlogDelete extends Command { //############################################################################ // doExecute //############################################################################ function doExecute(Request $request) { // Get data from request $id = $request->getProperty('id'); // Create manager object $manager = new ManagerMessage(); // Add to database $manager->deleteMessage($id); // Redirect to index header("location:index.php"); } } ?>
  25. Ok i think that it has something to do with not clearing the Cache, although i am not really sure how to test that. Answers on a postcard to.......
×
×
  • 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.